radv: move lowering the view index to radv_pipeline_link_shaders()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 19 Aug 2022 10:41:39 +0000 (12:41 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 22 Aug 2022 13:45:28 +0000 (13:45 +0000)
This is a link step because it needs to know if the previous stage is
a mesh shader.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18138>

src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader.h

index e3386ec..40ec9cb 100644 (file)
@@ -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;
       }
index 2751470..2259865 100644 (file)
@@ -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);
    }
 
index 40b8bb9..66f66e5 100644 (file)
@@ -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);