Skip to content
Snippets Groups Projects

d3d11: invalidate cache key on load failure

Closed Kacper Michajłow requested to merge kasper93/libplacebo:d3d11_c into master
1 unresolved thread
1 file
+ 9
9
Compare changes
  • Side-by-side
  • Inline
+ 9
9
@@ -508,7 +508,7 @@ struct d3d11_cache_header {
size_t comp_bc_len;
};
static inline uint64_t pass_cache_signature(pl_gpu gpu, uint64_t *key,
static inline uint64_t pass_cache_signature(pl_gpu gpu,
const struct pl_pass_params *params)
{
struct pl_gpu_d3d11 *p = PL_PRIV(gpu);
@@ -519,10 +519,6 @@ static inline uint64_t pass_cache_signature(pl_gpu gpu, uint64_t *key,
if (params->type == PL_PASS_RASTER)
pl_hash_merge(&hash, pl_str0_hash(params->vertex_shader));
// store hash based on the shader bodys as the lookup key
if (key)
*key = hash;
// and add the compiler version information into the verification signature
pl_hash_merge(&hash, p->spirv->signature);
@@ -563,25 +559,25 @@ static bool d3d11_use_cached_program(pl_gpu gpu, struct pl_pass_t *pass,
if (!gpu_cache)
return false;
*out_sig = pass_cache_signature(gpu, &obj->key, params);
*out_sig = obj->key = pass_cache_signature(gpu, params);
if (!pl_cache_get(gpu_cache, obj))
return false;
pl_str cache = (pl_str) { obj->data, obj->size };
if (cache.len < sizeof(struct d3d11_cache_header))
return false;
goto invalid;
struct d3d11_cache_header *header = (struct d3d11_cache_header *) cache.buf;
cache = pl_str_drop(cache, sizeof(*header));
if (header->hash != *out_sig)
return false;
goto invalid;
// determine required cache size before reading anything
size_t required = cache_payload_size(header);
if (cache.len < required)
return false;
goto invalid;
pass_p->num_workgroups_used = header->num_workgroups_used;
@@ -614,6 +610,10 @@ static bool d3d11_use_cached_program(pl_gpu gpu, struct pl_pass_t *pass,
GET_SHADER(comp_bc);
return true;
invalid:
pl_cache_set(gpu_cache, &(pl_cache_obj){ .key = obj->key });
return false;
}
static void d3d11_update_program_cache(pl_gpu gpu, struct pl_pass_t *pass,
Loading