From 5d8b53beeaffa8de778f70355275e2b0d348df5f Mon Sep 17 00:00:00 2001 From: "kingstom.chen" Date: Fri, 20 Mar 2026 16:38:51 +0800 Subject: [PATCH] radv/rt: only run move_rt_instructions() for CPS shaders move_rt_instructions() only makes sense for CPS recursive shaders, where later rt_trace_ray calls can overwrite the current shader's RT system values. Running it on the function-call path can hoist load_hit_attrib_amd above merged intersection writes, which corrupts any-hit hitAttributeEXT. Move the pass into the existing CPS-only non-intersection branch before nir_lower_shader_calls(). Fixes: c5d796c902ce ("radv/rt: Use function call structure in NIR lowering") Closes: #15074 Reviewed-by: Konstantin Seurer (cherry picked from commit 5a7f4c62d8538ad643644a0ea98bcea79039d837) Part-of: --- .pick_status.json | 2 +- src/amd/vulkan/radv_pipeline_rt.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index b889e7932b3..2ebab780b31 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3804,7 +3804,7 @@ "description": "radv/rt: only run move_rt_instructions() for CPS shaders", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c5d796c902cef0518505bf79b0cdf0c88f1c1d16", "notes": null diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 12576f7af8b..e3e5774539f 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -409,16 +409,16 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache, stage->info.inline_push_constant_mask = stage->args.ac.inline_push_const_mask; stage->info.type = radv_is_traversal_shader(stage->nir) ? RADV_SHADER_TYPE_RT_TRAVERSAL : RADV_SHADER_TYPE_DEFAULT; - /* Move ray tracing system values to the top that are set by rt_trace_ray - * to prevent them from being overwritten by other rt_trace_ray calls. - */ - NIR_PASS(_, stage->nir, move_rt_instructions); - uint32_t num_resume_shaders = 0; nir_shader **resume_shaders = NULL; void *mem_ctx = ralloc_context(NULL); if (stage->stage != MESA_SHADER_INTERSECTION && mode == RADV_RT_LOWERING_MODE_CPS) { + /* Move ray tracing system values to the top that are set by rt_trace_ray + * to prevent them from being overwritten by other rt_trace_ray calls. + */ + NIR_PASS(_, stage->nir, move_rt_instructions); + nir_builder b = nir_builder_at(nir_after_impl(nir_shader_get_entrypoint(stage->nir))); nir_rt_return_amd(&b);