Revert "tgsi/scan: don't set interp flags for inputs only used by INTERP instructions"
authorMarek Olšák <marek.olsak@amd.com>
Wed, 14 Sep 2016 22:46:26 +0000 (00:46 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 14 Sep 2016 22:47:24 +0000 (00:47 +0200)
This reverts commit 524fd55d2d973f50a5d8bc2255684610f5faae32.

Reason: https://bugs.freedesktop.org/show_bug.cgi?id=97808

src/gallium/auxiliary/tgsi/tgsi_scan.c

index 39e4dd93e63001c848f8aa188b882652b008ac5d..a3b0d9f41293d9e5ebc7e7efd5d61c5f6106d4d8 100644 (file)
@@ -102,7 +102,6 @@ scan_instruction(struct tgsi_shader_info *info,
 {
    unsigned i;
    bool is_mem_inst = false;
-   bool is_interp_instruction = false;
 
    assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
    info->opcode_count[fullinst->Instruction.Opcode]++;
@@ -128,8 +127,6 @@ scan_instruction(struct tgsi_shader_info *info,
       const struct tgsi_full_src_register *src0 = &fullinst->Src[0];
       unsigned input;
 
-      is_interp_instruction = true;
-
       if (src0->Register.Indirect && src0->Indirect.ArrayID)
          input = info->input_array_first[src0->Indirect.ArrayID];
       else
@@ -193,16 +190,12 @@ scan_instruction(struct tgsi_shader_info *info,
             info->input_usage_mask[ind] |= usage_mask;
          }
 
-         if (info->processor == PIPE_SHADER_FRAGMENT) {
-            unsigned name, index, input;
-
-            if (src->Register.Indirect && src->Indirect.ArrayID)
-               input = info->input_array_first[src->Indirect.ArrayID];
-            else
-               input = src->Register.Index;
-
-            name = info->input_semantic_name[input];
-            index = info->input_semantic_index[input];
+         if (info->processor == PIPE_SHADER_FRAGMENT &&
+             !src->Register.Indirect) {
+            unsigned name =
+               info->input_semantic_name[src->Register.Index];
+            unsigned index =
+               info->input_semantic_index[src->Register.Index];
 
             if (name == TGSI_SEMANTIC_POSITION &&
                 (src->Register.SwizzleX == TGSI_SWIZZLE_Z ||
@@ -220,50 +213,6 @@ scan_instruction(struct tgsi_shader_info *info,
 
                info->colors_read |= mask << (index * 4);
             }
-
-            /* Process only interpolated varyings. Don't include POSITION.
-             * Don't include integer varyings, because they are not
-             * interpolated. Don't process inputs interpolated by INTERP
-             * opcodes. Those are tracked separately.
-             */
-            if ((!is_interp_instruction || i != 0) &&
-                (name == TGSI_SEMANTIC_GENERIC ||
-                 name == TGSI_SEMANTIC_TEXCOORD ||
-                 name == TGSI_SEMANTIC_COLOR ||
-                 name == TGSI_SEMANTIC_BCOLOR ||
-                 name == TGSI_SEMANTIC_FOG ||
-                 name == TGSI_SEMANTIC_CLIPDIST)) {
-               switch (info->input_interpolate[index]) {
-               case TGSI_INTERPOLATE_COLOR:
-               case TGSI_INTERPOLATE_PERSPECTIVE:
-                  switch (info->input_interpolate_loc[index]) {
-                  case TGSI_INTERPOLATE_LOC_CENTER:
-                     info->uses_persp_center = TRUE;
-                     break;
-                  case TGSI_INTERPOLATE_LOC_CENTROID:
-                     info->uses_persp_centroid = TRUE;
-                     break;
-                  case TGSI_INTERPOLATE_LOC_SAMPLE:
-                     info->uses_persp_sample = TRUE;
-                     break;
-                  }
-                  break;
-               case TGSI_INTERPOLATE_LINEAR:
-                  switch (info->input_interpolate_loc[index]) {
-                  case TGSI_INTERPOLATE_LOC_CENTER:
-                     info->uses_linear_center = TRUE;
-                     break;
-                  case TGSI_INTERPOLATE_LOC_CENTROID:
-                     info->uses_linear_centroid = TRUE;
-                     break;
-                  case TGSI_INTERPOLATE_LOC_SAMPLE:
-                     info->uses_linear_sample = TRUE;
-                     break;
-                  }
-                  break;
-                  /* TGSI_INTERPOLATE_CONSTANT doesn't do any interpolation. */
-               }
-            }
          }
       }
 
@@ -408,6 +357,48 @@ scan_declaration(struct tgsi_shader_info *info,
             assert(reg < info->num_inputs);
          }
 
+         /* Only interpolated varyings. Don't include POSITION.
+          * Don't include integer varyings, because they are not
+          * interpolated.
+          */
+         if (semName == TGSI_SEMANTIC_GENERIC ||
+             semName == TGSI_SEMANTIC_TEXCOORD ||
+             semName == TGSI_SEMANTIC_COLOR ||
+             semName == TGSI_SEMANTIC_BCOLOR ||
+             semName == TGSI_SEMANTIC_FOG ||
+             semName == TGSI_SEMANTIC_CLIPDIST) {
+            switch (fulldecl->Interp.Interpolate) {
+            case TGSI_INTERPOLATE_COLOR:
+            case TGSI_INTERPOLATE_PERSPECTIVE:
+               switch (fulldecl->Interp.Location) {
+               case TGSI_INTERPOLATE_LOC_CENTER:
+                  info->uses_persp_center = TRUE;
+                  break;
+               case TGSI_INTERPOLATE_LOC_CENTROID:
+                  info->uses_persp_centroid = TRUE;
+                  break;
+               case TGSI_INTERPOLATE_LOC_SAMPLE:
+                  info->uses_persp_sample = TRUE;
+                  break;
+               }
+               break;
+            case TGSI_INTERPOLATE_LINEAR:
+               switch (fulldecl->Interp.Location) {
+               case TGSI_INTERPOLATE_LOC_CENTER:
+                  info->uses_linear_center = TRUE;
+                  break;
+               case TGSI_INTERPOLATE_LOC_CENTROID:
+                  info->uses_linear_centroid = TRUE;
+                  break;
+               case TGSI_INTERPOLATE_LOC_SAMPLE:
+                  info->uses_linear_sample = TRUE;
+                  break;
+               }
+               break;
+               /* TGSI_INTERPOLATE_CONSTANT doesn't do any interpolation. */
+            }
+         }
+
          if (semName == TGSI_SEMANTIC_PRIMID)
             info->uses_primid = TRUE;
          else if (procType == PIPE_SHADER_FRAGMENT) {