radv: handle per_vertex variables when gathering FS inputs
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 31 May 2023 07:44:21 +0000 (09:44 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 7 Jun 2023 14:40:35 +0000 (14:40 +0000)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16742>

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

index 49b3baf..956c7f3 100644 (file)
@@ -345,6 +345,7 @@ struct radv_shader_info {
       uint32_t input_per_primitive_mask;
       uint32_t flat_shaded_mask;
       uint32_t explicit_shaded_mask;
+      uint32_t per_vertex_shaded_mask;
       uint32_t float16_shaded_mask;
       uint32_t num_interp;
       uint32_t num_prim_interp;
index 094289d..049cd8b 100644 (file)
@@ -615,7 +615,9 @@ gather_shader_info_fs(const struct radv_device *device, const nir_shader *nir,
    info->ps.spi_shader_col_format = pipeline_key->ps.epilog.spi_shader_col_format;
 
    nir_foreach_shader_in_variable(var, nir) {
-      unsigned attrib_count = glsl_count_attribute_slots(var->type, false);
+      const struct glsl_type *type =
+         var->data.per_vertex ? glsl_get_array_element(var->type) : var->type;
+      unsigned attrib_count = glsl_count_attribute_slots(type, false);
       int idx = var->data.location;
 
       switch (idx) {
@@ -631,7 +633,7 @@ gather_shader_info_fs(const struct radv_device *device, const nir_shader *nir,
          unsigned component_count = var->data.location_frac + glsl_get_length(var->type);
          attrib_count = (component_count + 3) / 4;
       } else {
-         mark_16bit_ps_input(info, var->type, var->data.driver_location);
+         mark_16bit_ps_input(info, type, var->data.driver_location);
       }
 
       uint64_t mask = ((1ull << attrib_count) - 1);
@@ -641,6 +643,8 @@ gather_shader_info_fs(const struct radv_device *device, const nir_shader *nir,
             info->ps.flat_shaded_mask |= mask << var->data.driver_location;
          else if (var->data.interpolation == INTERP_MODE_EXPLICIT)
             info->ps.explicit_shaded_mask |= mask << var->data.driver_location;
+         else if (var->data.per_vertex)
+            info->ps.per_vertex_shaded_mask |= mask << var->data.driver_location;
       }
 
       if (var->data.location >= VARYING_SLOT_VAR0) {