radeonsi: get color interpolation info from shader_info
authorMarek Olšák <marek.olsak@amd.com>
Fri, 14 Aug 2020 23:13:21 +0000 (19:13 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 3 Sep 2020 02:45:38 +0000 (22:45 -0400)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6445>

src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_nir.c

index b6b11292d7a3434127816ff625c63750468cf6c3..0558cda194adec35f1098be7252a48c46146c96b 100644 (file)
@@ -2143,8 +2143,8 @@ void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *ke
       }
 
       for (unsigned i = 0; i < 2; i++) {
-         unsigned interp = info->input_interpolate[color[i]];
-         unsigned location = info->input_interpolate_loc[color[i]];
+         unsigned interp = info->color_interpolate[i];
+         unsigned location = info->color_interpolate_loc[i];
 
          if (!(info->colors_read & (0xf << i * 4)))
             continue;
index b46a48380e035d8aa930888ab2901a4bad728bf3..95b0c05033985f6edfe167290040ab7553248057 100644 (file)
@@ -324,13 +324,15 @@ struct si_shader_info {
    ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
    ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
    ubyte input_interpolate[PIPE_MAX_SHADER_INPUTS];
-   ubyte input_interpolate_loc[PIPE_MAX_SHADER_INPUTS];
    ubyte input_usage_mask[PIPE_MAX_SHADER_INPUTS];
    ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
    ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
    ubyte output_usagemask[PIPE_MAX_SHADER_OUTPUTS];
    ubyte output_streams[PIPE_MAX_SHADER_OUTPUTS];
 
+   ubyte color_interpolate[2];
+   ubyte color_interpolate_loc[2];
+
    ubyte processor;
 
    int constbuf0_num_slots;
index 19c9332408a8bd0c966f083501234e435679789f..c4578d529a6eb6af344d550b9473c881360fd699 100644 (file)
@@ -598,6 +598,15 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
             unreachable("Unknow depth layout");
          }
       }
+
+      info->color_interpolate[0] = tgsi_get_interp_mode(nir->info.fs.color0_interp, true);
+      info->color_interpolate[1] = tgsi_get_interp_mode(nir->info.fs.color1_interp, true);
+      info->color_interpolate_loc[0] = nir->info.fs.color0_sample ? TGSI_INTERPOLATE_LOC_SAMPLE :
+                                       nir->info.fs.color0_centroid ? TGSI_INTERPOLATE_LOC_CENTROID :
+                                                                      TGSI_INTERPOLATE_LOC_CENTER;
+      info->color_interpolate_loc[1] = nir->info.fs.color1_sample ? TGSI_INTERPOLATE_LOC_SAMPLE :
+                                       nir->info.fs.color1_centroid ? TGSI_INTERPOLATE_LOC_CENTROID :
+                                                                      TGSI_INTERPOLATE_LOC_CENTER;
    }
 
    if (gl_shader_stage_is_compute(nir->info.stage)) {
@@ -647,16 +656,6 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
          if (semantic_name == TGSI_SEMANTIC_PRIMID)
             info->uses_primid = true;
 
-         if (semantic_name == TGSI_SEMANTIC_COLOR) {
-            /* We only need this for color inputs. */
-            if (variable->data.sample)
-               info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_SAMPLE;
-            else if (variable->data.centroid)
-               info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_CENTROID;
-            else
-               info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_CENTER;
-         }
-
          enum glsl_base_type base_type = glsl_get_base_type(glsl_without_array(variable->type));
 
          switch (variable->data.interpolation) {
@@ -853,8 +852,14 @@ static void si_nir_lower_color(nir_shader *nir)
 
          if (var->data.location == VARYING_SLOT_COL0) {
             def = nir_load_color0(&b);
+            nir->info.fs.color0_interp = var->data.interpolation;
+            nir->info.fs.color0_sample = var->data.sample;
+            nir->info.fs.color0_centroid = var->data.centroid;
          } else if (var->data.location == VARYING_SLOT_COL1) {
             def = nir_load_color1(&b);
+            nir->info.fs.color1_interp = var->data.interpolation;
+            nir->info.fs.color1_sample = var->data.sample;
+            nir->info.fs.color1_centroid = var->data.centroid;
          } else {
             continue;
          }