From d1cf01dc5275bf058ae6d59a27ba1967e7edc3bc Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 5 Mar 2024 12:44:55 -0600 Subject: [PATCH] vulkan/pipeline: Always init pipeline cache objects vk_shader_init_cache_obj() is fast enough and the already-found case is rare enough that there's no good reason to avoid the init. This allows us to use vk_shader_unref instead of vk_shader_destroy which is probably a touch safer over-all. It also fixes the assert that the two shaders have matching keys. Fixes: bb8b11d80697 ("vulkan/pipeline: Handle fully compiled library shaders properly") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10752 Reviewed-By: Mike Blumenkrantz Part-of: --- src/vulkan/runtime/vk_pipeline.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vulkan/runtime/vk_pipeline.c b/src/vulkan/runtime/vk_pipeline.c index c9852a0ee96..e14fdab9cb2 100644 --- a/src/vulkan/runtime/vk_pipeline.c +++ b/src/vulkan/runtime/vk_pipeline.c @@ -1375,11 +1375,11 @@ vk_graphics_pipeline_compile_shaders(struct vk_device *device, for (uint32_t i = partition[p]; i < partition[p + 1]; i++) { struct vk_pipeline_stage *stage = &stages[i]; - if (stage->shader == NULL) { - shader_key.stage = stage->stage; - vk_shader_init_cache_obj(device, shaders[i], &shader_key, - sizeof(shader_key)); + shader_key.stage = stage->stage; + vk_shader_init_cache_obj(device, shaders[i], &shader_key, + sizeof(shader_key)); + if (stage->shader == NULL) { struct vk_pipeline_cache_object *cache_obj = &shaders[i]->pipeline.cache_obj; if (cache != NULL) @@ -1395,7 +1395,8 @@ vk_graphics_pipeline_compile_shaders(struct vk_device *device, assert(memcmp(&stage->shader->pipeline.cache_key, &shaders[i]->pipeline.cache_key, sizeof(shaders[i]->pipeline.cache_key)) == 0); - vk_shader_destroy(device, shaders[i], &device->alloc); + + vk_shader_unref(device, shaders[i]); } stage_feedbacks[stage->stage].duration += part_end - part_start;