vulkan/pipeline_cache: replace raw data objects on cache insertion of real objects

It might happen that a raw data object (from pipeline cache creation)
was never looked up, and thus never deserialized, before it gets
inserted again into the cache. In this case, the deserialized object
got replaced by the raw data object.
Instead, replace the raw data object with the real object in the cache.

Fixes: 8b13ee75ba ('vulkan: Fall back to raw data objects when deserializing if ops == NULL')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22735>
(cherry picked from commit cbab396f54)
This commit is contained in:
Daniel Schürmann 2023-04-27 15:13:51 +02:00 committed by Eric Engestrom
parent e2ccae5fae
commit 6ad6513226
2 changed files with 10 additions and 1 deletions

View file

@ -364,7 +364,7 @@
"description": "vulkan/pipeline_cache: replace raw data objects on cache insertion of real objects",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "8b13ee75ba9f27ceac6b6180ca05d321caa13612"
},

View file

@ -319,6 +319,15 @@ vk_pipeline_cache_insert_object(struct vk_pipeline_cache *cache,
struct vk_pipeline_cache_object *result = NULL;
/* add reference to either the found or inserted object */
if (found) {
struct vk_pipeline_cache_object *found_object = (void *)entry->key;
if (found_object->ops != object->ops) {
/* The found object in the cache isn't fully formed. Replace it. */
assert(found_object->ops == &raw_data_object_ops);
assert(found_object->ref_cnt == 1 && object->ref_cnt == 1);
entry->key = object;
object = found_object;
}
result = vk_pipeline_cache_object_ref((void *)entry->key);
} else {
result = vk_pipeline_cache_object_ref(object);