| 1972 | } |
| 1973 | |
| 1974 | s32 parse_sampler_states(const char *json) |
| 1975 | { |
| 1976 | TempAllocator4096 ta; |
| 1977 | JsonObject sampler_states(ta); |
| 1978 | RETURN_IF_ERROR(sjson::parse_object(sampler_states, json)); |
| 1979 | |
| 1980 | auto cur = json_object::begin(sampler_states); |
| 1981 | auto end = json_object::end(sampler_states); |
| 1982 | for (; cur != end; ++cur) { |
| 1983 | JSON_OBJECT_SKIP_HOLE(sampler_states, cur); |
| 1984 | |
| 1985 | JsonObject obj(ta); |
| 1986 | RETURN_IF_ERROR(sjson::parse_object(obj, cur->second)); |
| 1987 | |
| 1988 | const bool has_filter_min = json_object::has(obj, "filter_min"); |
| 1989 | const bool has_filter_mag = json_object::has(obj, "filter_mag"); |
| 1990 | const bool has_wrap_u = json_object::has(obj, "wrap_u"); |
| 1991 | const bool has_wrap_v = json_object::has(obj, "wrap_v"); |
| 1992 | const bool has_wrap_w = json_object::has(obj, "wrap_w"); |
| 1993 | |
| 1994 | SamplerState ss; |
| 1995 | ss.reset(); |
| 1996 | |
| 1997 | DynamicString filter_min(ta); |
| 1998 | DynamicString filter_mag(ta); |
| 1999 | DynamicString wrap_u(ta); |
| 2000 | DynamicString wrap_v(ta); |
| 2001 | DynamicString wrap_w(ta); |
| 2002 | |
| 2003 | if (has_filter_min) { |
| 2004 | RETURN_IF_ERROR(sjson::parse_string(filter_min, obj["filter_min"])); |
| 2005 | ss._filter_min = name_to_sampler_filter(filter_min.c_str()); |
| 2006 | RETURN_IF_FALSE(SHADER_RESOURCE, ss._filter_min != SamplerFilter::COUNT |
| 2007 | , _opts |
| 2008 | , "Unknown sampler filter: '%s'" |
| 2009 | , filter_min.c_str() |
| 2010 | ); |
| 2011 | } |
| 2012 | |
| 2013 | if (has_filter_mag) { |
| 2014 | RETURN_IF_ERROR(sjson::parse_string(filter_mag, obj["filter_mag"])); |
| 2015 | ss._filter_mag = name_to_sampler_filter(filter_mag.c_str()); |
| 2016 | RETURN_IF_FALSE(SHADER_RESOURCE, ss._filter_mag != SamplerFilter::COUNT |
| 2017 | , _opts |
| 2018 | , "Unknown sampler filter: '%s'" |
| 2019 | , filter_mag.c_str() |
| 2020 | ); |
| 2021 | } |
| 2022 | |
| 2023 | if (has_wrap_u) { |
| 2024 | RETURN_IF_ERROR(sjson::parse_string(wrap_u, obj["wrap_u"])); |
| 2025 | ss._wrap_u = name_to_sampler_wrap(wrap_u.c_str()); |
| 2026 | RETURN_IF_FALSE(SHADER_RESOURCE, ss._wrap_u != SamplerWrap::COUNT |
| 2027 | , _opts |
| 2028 | , "Unknown wrap mode: '%s'" |
| 2029 | , wrap_u.c_str() |
| 2030 | ); |
| 2031 | } |
nothing calls this directly
no test coverage detected