[Mesa-dev] [PATCH v2 02/13] tgsi/scan: fix num_inputs/num_outputs for shaders with overlapping arrays

Nicolai Hähnle nhaehnle at gmail.com
Mon Oct 10 08:32:14 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index c7745ce..85ab329 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -394,26 +394,23 @@ scan_declaration(struct tgsi_shader_info *info,
             MAX2(info->const_file_max[buffer], (int)reg);
       }
       else if (file == TGSI_FILE_INPUT) {
          info->input_semantic_name[reg] = (ubyte) semName;
          info->input_semantic_index[reg] = (ubyte) semIndex;
          info->input_interpolate[reg] = (ubyte)fulldecl->Interp.Interpolate;
          info->input_interpolate_loc[reg] = (ubyte)fulldecl->Interp.Location;
          info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Interp.CylindricalWrap;
 
          /* Vertex shaders can have inputs with holes between them. */
-         if (info->processor == PIPE_SHADER_VERTEX)
-            info->num_inputs = MAX2(info->num_inputs, reg + 1);
-         else {
-            info->num_inputs++;
+         info->num_inputs = MAX2(info->num_inputs, reg + 1);
+         if (info->processor != PIPE_SHADER_VERTEX)
             assert(reg < info->num_inputs);
-         }
 
          if (semName == TGSI_SEMANTIC_PRIMID)
             info->uses_primid = TRUE;
          else if (procType == PIPE_SHADER_FRAGMENT) {
             if (semName == TGSI_SEMANTIC_POSITION)
                info->reads_position = TRUE;
             else if (semName == TGSI_SEMANTIC_FACE)
                info->uses_frontface = TRUE;
          }
       }
@@ -449,21 +446,21 @@ scan_declaration(struct tgsi_shader_info *info,
             info->uses_frontface = TRUE;
             break;
          case TGSI_SEMANTIC_SAMPLEMASK:
             info->reads_samplemask = TRUE;
             break;
          }
       }
       else if (file == TGSI_FILE_OUTPUT) {
          info->output_semantic_name[reg] = (ubyte) semName;
          info->output_semantic_index[reg] = (ubyte) semIndex;
-         info->num_outputs++;
+         info->num_outputs = MAX2(info->num_outputs, reg + 1);
          assert(reg < info->num_outputs);
 
          if (semName == TGSI_SEMANTIC_COLOR)
             info->colors_written |= 1 << semIndex;
 
          if (procType == PIPE_SHADER_VERTEX ||
              procType == PIPE_SHADER_GEOMETRY ||
              procType == PIPE_SHADER_TESS_CTRL ||
              procType == PIPE_SHADER_TESS_EVAL) {
             switch (semName) {
-- 
2.7.4



More information about the mesa-dev mailing list