tgsi: Do not assume IN and OUT registers are declared sequentially.
authorMichal Krol <michal@tungstengraphics.com>
Fri, 2 May 2008 09:13:58 +0000 (11:13 +0200)
committerMichal Krol <michal@tungstengraphics.com>
Fri, 2 May 2008 09:13:58 +0000 (11:13 +0200)
src/gallium/auxiliary/tgsi/util/tgsi_scan.c

index ea4a72967d6182b9c7f3213169a9017b8040e73a..65650ed22a4d8d4b06212a0f8256591e7f772cb8 100644 (file)
@@ -103,18 +103,14 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                info->file_max[file] = MAX2(info->file_max[file], (int)i);
 
                if (file == TGSI_FILE_INPUT) {
-                  info->input_semantic_name[info->num_inputs]
-                     = (ubyte)fulldecl->Semantic.SemanticName;
-                  info->input_semantic_index[info->num_inputs]
-                     = (ubyte)fulldecl->Semantic.SemanticIndex;
+                  info->input_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName;
+                  info->input_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex;
                   info->num_inputs++;
                }
 
                if (file == TGSI_FILE_OUTPUT) {
-                  info->output_semantic_name[info->num_outputs]
-                     = (ubyte)fulldecl->Semantic.SemanticName;
-                  info->output_semantic_index[info->num_outputs]
-                     = (ubyte)fulldecl->Semantic.SemanticIndex;
+                  info->output_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName;
+                  info->output_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex;
                   info->num_outputs++;
                }
 
@@ -137,6 +133,9 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
       }
    }
 
+   assert( info->file_max[TGSI_FILE_INPUT] + 1 == info->num_inputs );
+   assert( info->file_max[TGSI_FILE_OUTPUT] + 1 == info->num_outputs );
+
    info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
                       info->opcode_count[TGSI_OPCODE_KILP]);