From 1dd9c572330917d73a8fc6bd6724f8fda8e1a63b Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 15 Apr 2026 13:58:32 +0200 Subject: [PATCH] radv: move fs view_index handling after lowering io And update the comment to reflect that we now use a sysval to load the layer id. Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/nir/radv_nir_lower_view_index.c | 7 +------ src/amd/vulkan/radv_pipeline_graphics.c | 13 +++---------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/amd/vulkan/nir/radv_nir_lower_view_index.c b/src/amd/vulkan/nir/radv_nir_lower_view_index.c index 74dc1190599..8d6b60ab493 100644 --- a/src/amd/vulkan/nir/radv_nir_lower_view_index.c +++ b/src/amd/vulkan/nir/radv_nir_lower_view_index.c @@ -12,12 +12,7 @@ /** * We use layered rendering to implement multiview, which means we need to map - * view_index to gl_Layer. The code generates a load from the layer_id sysval, - * but since we don't have a way to get at this information from the fragment - * shader, we also need to lower this to the gl_Layer varying. This pass - * lowers both to a varying load from the LAYER slot, before lowering io, so - * that nir_assign_var_locations() will give the LAYER varying the correct - * driver_location. + * view_index to gl_Layer in the fragment shader. */ static bool pass(nir_builder *b, nir_intrinsic_instr *intr, void *_) diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 9e6e85df6cd..3dfda1f67a7 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -1269,15 +1269,6 @@ radv_link_mesh(struct radv_shader_stage *mesh_stage, struct radv_shader_stage *f radv_nir_lower_draw_id_to_zero(mesh_stage->nir); } -static void -radv_link_fs(struct radv_shader_stage *fs_stage, const struct radv_graphics_state_key *gfx_state) -{ - assert(fs_stage->nir->info.stage == MESA_SHADER_FRAGMENT); - - /* Lower the view index to map on the layer. */ - NIR_PASS(_, fs_stage->nir, radv_nir_lower_view_index); -} - static bool radv_pipeline_needs_noop_fs(struct radv_graphics_pipeline *pipeline, const struct radv_graphics_state_key *gfx_state) { @@ -1323,7 +1314,6 @@ radv_graphics_shaders_link(const struct radv_device *device, const struct radv_g radv_link_mesh(&stages[s], next_stage, gfx_state); break; case MESA_SHADER_FRAGMENT: - radv_link_fs(&stages[s], gfx_state); break; default: UNREACHABLE("Invalid graphics shader stage"); @@ -2679,6 +2669,9 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, nir_opt_copy_prop); NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, nir_opt_dce); NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, nir_opt_frag_coord_to_pixel_coord); + + /* Lower the view index to map on the layer. */ + NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, radv_nir_lower_view_index); } radv_foreach_stage (i, active_nir_stages) {