From ba967e1a28c179d32ba0af2fb61759fd32a353d7 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 6 Jan 2023 09:27:30 +0100 Subject: [PATCH] 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: --- src/amd/vulkan/radv_pipeline_cache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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]); -- 2.7.4