From 8a78fbb8324928cf2618b08e8bfaa6220ed5f879 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 19 Aug 2022 12:41:39 +0200 Subject: [PATCH] radv: move lowering the view index to radv_pipeline_link_shaders() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a link step because it needs to know if the previous stage is a mesh shader. Signed-off-by: Samuel Pitoiset Reviewed-By: Mike Blumenkrantz Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/radv_pipeline.c | 5 ++++- src/amd/vulkan/radv_shader.c | 7 +++---- src/amd/vulkan/radv_shader.h | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index e3386ec008d..40ec9cbdb34 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -2716,6 +2716,9 @@ radv_pipeline_link_shaders(const struct radv_device *device, !(producer->info.outputs_written & VARYING_BIT_LAYER)) { NIR_PASS(_, producer, radv_lower_multiview); } + + /* Lower the view index to map on the layer. */ + NIR_PASS(_, consumer, radv_lower_view_index, producer->info.stage == MESA_SHADER_MESH); } if (pipeline_key->optimisations_disabled) @@ -4719,7 +4722,7 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout /* Gather info again, information such as outputs_read can be out-of-date. */ nir_shader_gather_info(stages[i].nir, nir_shader_get_entrypoint(stages[i].nir)); - radv_lower_io(device, stages[i].nir, stages[MESA_SHADER_MESH].nir); + radv_lower_io(device, stages[i].nir); stages[i].feedback.duration += os_time_get_nano() - stage_start; } diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 2751470af1a..225986573f0 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1089,8 +1089,8 @@ find_layer_in_var(nir_shader *nir) * driver_location. */ -static bool -lower_view_index(nir_shader *nir, bool per_primitive) +bool +radv_lower_view_index(nir_shader *nir, bool per_primitive) { bool progress = false; nir_function_impl *entry = nir_shader_get_entrypoint(nir); @@ -1134,13 +1134,12 @@ lower_view_index(nir_shader *nir, bool per_primitive) } void -radv_lower_io(struct radv_device *device, nir_shader *nir, bool is_mesh_shading) +radv_lower_io(struct radv_device *device, nir_shader *nir) { if (nir->info.stage == MESA_SHADER_COMPUTE) return; if (nir->info.stage == MESA_SHADER_FRAGMENT) { - NIR_PASS(_, nir, lower_view_index, is_mesh_shading); nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs, MESA_SHADER_FRAGMENT); } diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 40b8bb917c0..66f66e5e621 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -732,10 +732,12 @@ get_tcs_num_patches(unsigned tcs_num_input_vertices, unsigned tcs_num_output_ver return num_patches; } -void radv_lower_io(struct radv_device *device, nir_shader *nir, bool is_mesh_shading); +void radv_lower_io(struct radv_device *device, nir_shader *nir); bool radv_lower_io_to_mem(struct radv_device *device, struct radv_pipeline_stage *stage); +bool radv_lower_view_index(nir_shader *nir, bool per_primitive); + void radv_lower_ngg(struct radv_device *device, struct radv_pipeline_stage *ngg_stage, const struct radv_pipeline_key *pl_key);