gallium: collect more shader info in tgsi_scan_shader()
authorBrian <brian.paul@tungstengraphics.com>
Tue, 26 Feb 2008 17:12:17 +0000 (10:12 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 26 Feb 2008 17:12:17 +0000 (10:12 -0700)
Now getting input/output semantic info so we can eventually remove those
fields from pipe_shader_state.

src/gallium/auxiliary/tgsi/util/tgsi_scan.c
src/gallium/auxiliary/tgsi/util/tgsi_scan.h

index 4b99ac37cce07cfd635566b16e3fdffb54028cd1..a1cc681492f30dbbd117d5819e02a49bc55e7e6c 100644 (file)
@@ -69,6 +69,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
     */
    while( !tgsi_parse_end_of_tokens( &parse ) ) {
 
+      info->num_tokens++;
+
       tgsi_parse_token( &parse );
 
       switch( parse.FullToken.Token.Type ) {
@@ -91,9 +93,27 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
             for (i = fulldecl->u.DeclarationRange.First;
                  i <= fulldecl->u.DeclarationRange.Last;
                  i++) {
+
+               /* only first 32 regs will appear in this bitfield */
                info->file_mask[file] |= (1 << i);
                info->file_count[file]++;
 
+               if (file == TGSI_FILE_INPUT) {
+                  info->input_semantic_name[info->num_inputs]
+                     = fulldecl->Semantic.SemanticName;
+                  info->input_semantic_index[info->num_inputs]
+                     = fulldecl->Semantic.SemanticIndex;
+                  info->num_inputs++;
+               }
+
+               if (file == TGSI_FILE_OUTPUT) {
+                  info->output_semantic_name[info->num_outputs]
+                     = fulldecl->Semantic.SemanticName;
+                  info->output_semantic_index[info->num_outputs]
+                     = fulldecl->Semantic.SemanticIndex;
+                  info->num_outputs++;
+               }
+
                /* special case */
                if (procType == TGSI_PROCESSOR_FRAGMENT &&
                    file == TGSI_FILE_OUTPUT &&
index 757446437c946bc23df4458e50159fd125ba19eb..dc6dfd6d0b33db2bba59be1f38532c47918b5ff9 100644 (file)
@@ -30,6 +30,7 @@
 
 
 #include "pipe/p_util.h"
+#include "pipe/p_state.h"
 #include "pipe/p_shader_tokens.h"
 
 
  */
 struct tgsi_shader_info
 {
+   uint num_tokens;
+
+   /* XXX eventually remove the corresponding fields from pipe_shader_state: */
+   ubyte num_inputs;
+   ubyte num_outputs;
+   ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
+   ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
+   ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
+   ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
+
    uint file_mask[TGSI_FILE_COUNT];  /**< bitmask of declared registers */
    uint file_count[TGSI_FILE_COUNT];  /**< number of declared registers */