From: Samuel Pitoiset Date: Fri, 6 Jan 2023 08:27:30 +0000 (+0100) Subject: radv: rely on non-NULL binaries when inserting shaders to the cache X-Git-Tag: upstream/23.3.3~10542 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba967e1a28c179d32ba0af2fb61759fd32a353d7;p=platform%2Fupstream%2Fmesa.git radv: rely on non-NULL binaries when inserting shaders to the cache With GPL, a stage can be imported from a library which means that the binary is NULL (it's freed right after compilation) but the shader is non-NULL. To avoid crashing, rely on non-NULL binaries because this implies that the shader is non-NULL as well. Signed-off-by: Samuel Pitoiset Part-of: --- diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 9980a4b..48802dc 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -482,7 +482,7 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel size_t size = sizeof(*entry) + sizeof(struct radv_pipeline_shader_stack_size) * num_rt_groups; for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) - if (pipeline->shaders[i]) + if (binaries[i]) size += binaries[i]->total_size; if (ps_epilog_binary) size += ps_epilog_binary->total_size; @@ -501,7 +501,7 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel char *p = entry->code; for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) { - if (!pipeline->shaders[i]) + if (!binaries[i]) continue; entry->binary_sizes[i] = binaries[i]->total_size; @@ -551,8 +551,9 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel * items. */ for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) { - if (!pipeline->shaders[i]) + if (!binaries[i]) continue; + assert(pipeline->shaders[i]); entry->shaders[i] = pipeline->shaders[i]; radv_shader_ref(pipeline->shaders[i]);