MCPcopy Create free account
hub / github.com/crownengine/crown / parse_static_compile

Method parse_static_compile

src/resource/shader_resource.cpp:2228–2261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2226 }
2227
2228 s32 parse_static_compile(const char *json)
2229 {
2230 TempAllocator4096 ta;
2231 JsonArray static_compile(ta);
2232 RETURN_IF_ERROR(sjson::parse_array(static_compile, json));
2233 HashSet<DynamicString> static_compile_variants(default_allocator());
2234
2235 for (u32 ii = 0; ii < array::size(static_compile); ++ii) {
2236 JsonObject obj(ta);
2237 RETURN_IF_ERROR(sjson::parse_object(obj, static_compile[ii]));
2238
2239 StaticCompile sc(default_allocator());
2240 RETURN_IF_ERROR(sjson::parse_string(sc._shader, obj["shader"]));
2241
2242 JsonArray defines(ta);
2243 RETURN_IF_ERROR(sjson::parse_array(defines, obj["defines"]));
2244 for (u32 jj = 0; jj < array::size(defines); ++jj) {
2245 DynamicString def(ta);
2246 RETURN_IF_ERROR(sjson::parse_string(def, defines[jj]));
2247 vector::push_back(sc._defines, def);
2248 }
2249 std::sort(vector::begin(sc._defines), vector::end(sc._defines));
2250
2251 DynamicString variant(ta);
2252 shader_variant(variant, sc._shader.c_str(), sc._defines);
2253 if (hash_set::has(static_compile_variants, variant))
2254 continue;
2255 hash_set::insert(static_compile_variants, variant);
2256
2257 vector::push_back(_static_compile, sc);
2258 }
2259
2260 return 0;
2261 }
2262
2263 void delete_temp_files()
2264 {

Callers

nothing calls this directly

Calls 9

parse_arrayFunction · 0.50
sizeFunction · 0.50
parse_objectFunction · 0.50
parse_stringFunction · 0.50
sortFunction · 0.50
beginFunction · 0.50
endFunction · 0.50
hasFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected