From 3fed41eadecbcc40ba1fd39213a72180109482bd Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 27 Jan 2026 10:54:42 +0000 Subject: [PATCH] radv: improve skipping of creation of NIR for cached rt pipeline libraries Signed-off-by: Rhys Perry Reviewed-by: Konstantin Seurer Part-of: --- src/amd/vulkan/radv_pipeline_cache.c | 7 +++++-- src/amd/vulkan/radv_pipeline_rt.c | 8 +++++--- src/amd/vulkan/radv_pipeline_rt.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 3e452637161..76dd141e04d 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -441,8 +441,9 @@ struct radv_ray_tracing_group_cache_data { }; struct radv_ray_tracing_stage_cache_data { - uint32_t stack_size : 31; + uint32_t stack_size : 30; uint32_t has_shader : 1; + uint32_t needs_nir : 1; uint8_t sha1[SHA1_DIGEST_LENGTH]; struct radv_ray_tracing_stage_info info; }; @@ -482,11 +483,12 @@ radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pip pipeline->stages[i].stack_size = data->stages[i].stack_size; pipeline->stages[i].info = data->stages[i].info; memcpy(pipeline->stages[i].sha1, data->stages[i].sha1, sizeof(pipeline->stages[i].sha1)); + pipeline->stages[i].needs_nir = data->stages[i].needs_nir; if (data->stages[i].has_shader) pipeline->stages[i].shader = radv_shader_ref(pipeline_obj->shaders[idx++]); - if (data->is_library) { + if (pipeline->stages[i].needs_nir) { pipeline->stages[i].nir = radv_pipeline_cache_lookup_nir_handle(device, cache, pipeline->stages[i].sha1); complete &= pipeline->stages[i].nir != NULL; } @@ -552,6 +554,7 @@ radv_ray_tracing_pipeline_cache_insert(struct radv_device *device, struct vk_pip data->stages[i].stack_size = pipeline->stages[i].stack_size; data->stages[i].info = pipeline->stages[i].info; data->stages[i].has_shader = !!pipeline->stages[i].shader; + data->stages[i].needs_nir = data->is_library && pipeline->stages[i].nir; memcpy(data->stages[i].sha1, pipeline->stages[i].sha1, sizeof(pipeline->stages[i].sha1)); if (pipeline->stages[i].shader) diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 201c3139bcd..76d13481f96 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -268,8 +268,10 @@ static void radv_rt_fill_stage_info(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, struct radv_ray_tracing_stage *stages) { uint32_t idx; - for (idx = 0; idx < pCreateInfo->stageCount; idx++) + for (idx = 0; idx < pCreateInfo->stageCount; idx++) { stages[idx].stage = vk_to_mesa_shader_stage(pCreateInfo->pStages[idx].stage); + stages[idx].needs_nir = true; + } if (pCreateInfo->pLibraryInfo) { for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) { @@ -674,7 +676,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca bool can_use_monolithic = !library && pipeline->stage_count < 50; for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { - if (rt_stages[i].nir) + if (rt_stages[i].nir || !rt_stages[i].needs_nir) continue; int64_t stage_start = os_time_get_nano(); @@ -749,7 +751,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca inline_any_hit_shaders |= raygen_lowering_mode == RADV_RT_LOWERING_MODE_MONOLITHIC && !raygen_imported; for (uint32_t idx = 0; idx < pCreateInfo->stageCount; idx++) { - if (rt_stages[idx].nir) + if (rt_stages[idx].nir || !rt_stages[idx].needs_nir) continue; int64_t stage_start = os_time_get_nano(); diff --git a/src/amd/vulkan/radv_pipeline_rt.h b/src/amd/vulkan/radv_pipeline_rt.h index af0d81e283a..da1b7c94758 100644 --- a/src/amd/vulkan/radv_pipeline_rt.h +++ b/src/amd/vulkan/radv_pipeline_rt.h @@ -100,6 +100,7 @@ struct radv_ray_tracing_stage { struct radv_shader *shader; mesa_shader_stage stage; uint32_t stack_size; + bool needs_nir; struct radv_ray_tracing_stage_info info;