| 1312 | } |
| 1313 | |
| 1314 | static bool load_metadata_cache(const DynamicString &cache_key |
| 1315 | , CompileOptions &opts |
| 1316 | , DynamicString &shader_library |
| 1317 | , Vector<UniformMetadata> *uniform_meta |
| 1318 | , Vector<ShaderResource::Sampler> *sampler_meta |
| 1319 | ) |
| 1320 | { |
| 1321 | if (!hash_map::has(metadata_cache(), cache_key)) |
| 1322 | return false; |
| 1323 | |
| 1324 | const MetadataCacheEntry cached(default_allocator()); |
| 1325 | const MetadataCacheEntry &entry = hash_map::get(metadata_cache(), cache_key, cached); |
| 1326 | |
| 1327 | // Cache hits skip opts.read(), so replay source dependencies for invalidation. |
| 1328 | for (u32 i = 0; i < vector::size(entry.dependencies); ++i) |
| 1329 | opts.fake_read(entry.dependencies[i].c_str()); |
| 1330 | |
| 1331 | shader_library = entry.shader_library; |
| 1332 | |
| 1333 | if (uniform_meta != NULL) |
| 1334 | *uniform_meta = entry.uniform_meta; |
| 1335 | |
| 1336 | if (sampler_meta != NULL) |
| 1337 | *sampler_meta = entry.sampler_meta; |
| 1338 | |
| 1339 | return true; |
| 1340 | } |
| 1341 | |
| 1342 | static void store_metadata_cache(const DynamicString &cache_key |
| 1343 | , const DynamicString &shader_library |