From cbab396f549fa7c1a948d469fe6b4df18a81adc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 27 Apr 2023 15:13:51 +0200 Subject: [PATCH] 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: 8b13ee75ba9f27ceac6b6180ca05d321caa13612 ('vulkan: Fall back to raw data objects when deserializing if ops == NULL') Part-of: --- src/vulkan/runtime/vk_pipeline_cache.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vulkan/runtime/vk_pipeline_cache.c b/src/vulkan/runtime/vk_pipeline_cache.c index 68014c7582a..d5b9f347daa 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.c +++ b/src/vulkan/runtime/vk_pipeline_cache.c @@ -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);