From 656d7e887ab1711c0a3f6606b53995cef878cad7 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 16 Sep 2024 17:51:09 +0200 Subject: [PATCH] radv: fix lowering the view index to an input varying for FS When multiview is used and the FS is compiled separately with GPL, the view index still needs to be lowered, otherwise it's crashing later. The lowering doesn't need to know the previous stage because ViewIndex is a global thing (ie. it's neither a per-vertex or a per-primitive varying). This fixes recent dEQP-VK.pipeline.pipeline_library.graphics_library.misc.other.view_index_from_device_index_*_pre_rasterization Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/nir/radv_nir.h | 2 +- src/amd/vulkan/nir/radv_nir_lower_view_index.c | 5 +---- src/amd/vulkan/radv_pipeline_graphics.c | 6 +++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/amd/vulkan/nir/radv_nir.h b/src/amd/vulkan/nir/radv_nir.h index c003438e325..e3a7a5a5a52 100644 --- a/src/amd/vulkan/nir/radv_nir.h +++ b/src/amd/vulkan/nir/radv_nir.h @@ -51,7 +51,7 @@ bool radv_nir_lower_fs_barycentric(nir_shader *shader, const struct radv_graphic bool radv_nir_lower_intrinsics_early(nir_shader *nir, bool lower_view_index_to_zero); -bool radv_nir_lower_view_index(nir_shader *nir, bool per_primitive); +bool radv_nir_lower_view_index(nir_shader *nir); bool radv_nir_lower_viewport_to_zero(nir_shader *nir); 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 e9eb424741f..62ab136ad5c 100644 --- a/src/amd/vulkan/nir/radv_nir_lower_view_index.c +++ b/src/amd/vulkan/nir/radv_nir_lower_view_index.c @@ -33,7 +33,7 @@ find_layer_in_var(nir_shader *nir) * driver_location. */ bool -radv_nir_lower_view_index(nir_shader *nir, bool per_primitive) +radv_nir_lower_view_index(nir_shader *nir) { bool progress = false; nir_function_impl *entry = nir_shader_get_entrypoint(nir); @@ -52,15 +52,12 @@ radv_nir_lower_view_index(nir_shader *nir, bool per_primitive) if (!layer) layer = find_layer_in_var(nir); - layer->data.per_primitive = per_primitive; b.cursor = nir_before_instr(instr); nir_def *def = nir_load_var(&b, layer); nir_def_rewrite_uses(&load->def, def); /* Update inputs_read to reflect that the pass added a new input. */ nir->info.inputs_read |= VARYING_BIT_LAYER; - if (per_primitive) - nir->info.per_primitive_inputs |= VARYING_BIT_LAYER; nir_instr_remove(instr); progress = true; diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 4cf67567ed1..8f3b2c02afc 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -1184,9 +1184,6 @@ radv_link_shaders(const struct radv_device *device, struct radv_shader_stage *pr !(producer->info.outputs_written & VARYING_BIT_VIEWPORT)) { NIR_PASS(_, consumer, radv_nir_lower_viewport_to_zero); } - - /* Lower the view index to map on the layer. */ - NIR_PASS(_, consumer, radv_nir_lower_view_index, producer->info.stage == MESA_SHADER_MESH); } if (producer_stage->key.optimisations_disabled || consumer_stage->key.optimisations_disabled) @@ -1383,6 +1380,9 @@ radv_link_fs(struct radv_shader_stage *fs_stage, const struct radv_graphics_stat { 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); + radv_remove_color_exports(gfx_state, fs_stage->nir); }