gallium/i915: Use tgsi_scan_shader() to collect shader info
authorBrian <brian@i915.localnet.net>
Tue, 26 Feb 2008 17:47:42 +0000 (10:47 -0700)
committerBrian <brian@i915.localnet.net>
Tue, 26 Feb 2008 17:47:42 +0000 (10:47 -0700)
No longer use semantic info in pipe_shader_state.
Also, remove redundant semantic info from i915_fp_compile struct.

src/gallium/drivers/i915simple/i915_context.h
src/gallium/drivers/i915simple/i915_fpc.h
src/gallium/drivers/i915simple/i915_fpc_translate.c
src/gallium/drivers/i915simple/i915_state.c
src/gallium/drivers/i915simple/i915_state_derived.c

index d32dded6bdc276d4c0909b098fca69074a2494b3..20cf7d3c3bf18e812a9f129f4fff83c651daa37e 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "draw/draw_vertex.h"
 
+#include "tgsi/util/tgsi_scan.h"
+
 
 #define I915_TEX_UNITS 8
 
@@ -89,6 +91,9 @@
 struct i915_fragment_shader
 {
    struct pipe_shader_state state;
+
+   struct tgsi_shader_info info;
+
    uint *program;
    uint program_len;
 
index 250dfe6dbf0b22ab1f68713fa8e65a4aa2f0b979..80a9576304ca417dbef1c80fe61a4d99842cba90 100644 (file)
@@ -58,12 +58,6 @@ struct i915_fp_compile {
    uint declarations[I915_PROGRAM_SIZE];
    uint program[I915_PROGRAM_SIZE];
 
-   uint input_semantic_name[PIPE_MAX_SHADER_INPUTS];
-   uint input_semantic_index[PIPE_MAX_SHADER_INPUTS];
-
-   uint output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
-   uint output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
-
    uint *csr;            /**< Cursor, points into program. */
 
    uint *decl;           /**< Cursor, points into declarations. */
index 76a2184e9aba87bc3a9f69cbbd2cb8c89700790d..c2d9a93c6c84d582cd15468a01db24a22760ffac 100644 (file)
@@ -162,8 +162,8 @@ src_vector(struct i915_fp_compile *p,
        * We also use a texture coordinate to pass wpos when possible.
        */
 
-      sem_name = p->input_semantic_name[index];
-      sem_ind = p->input_semantic_index[index];
+      sem_name = p->shader->info.input_semantic_name[index];
+      sem_ind = p->shader->info.input_semantic_index[index];
 
       switch (sem_name) {
       case TGSI_SEMANTIC_POSITION:
@@ -265,7 +265,7 @@ get_result_vector(struct i915_fp_compile *p,
    switch (dest->DstRegister.File) {
    case TGSI_FILE_OUTPUT:
       {
-         uint sem_name = p->output_semantic_name[dest->DstRegister.Index];
+         uint sem_name = p->shader->info.output_semantic_name[dest->DstRegister.Index];
          switch (sem_name) {
          case TGSI_SEMANTIC_POSITION:
             return UREG(REG_TYPE_OD, 0);
@@ -942,28 +942,6 @@ i915_translate_instructions(struct i915_fp_compile *p,
       switch( parse.FullToken.Token.Type ) {
       case TGSI_TOKEN_TYPE_DECLARATION:
          if (parse.FullToken.FullDeclaration.Declaration.File
-             == TGSI_FILE_INPUT) {
-            /* save input register info for use in src_vector() */
-            uint ind, sem, semi;
-            ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
-            sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
-            semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
-            /*debug_printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
-            p->input_semantic_name[ind] = sem;
-            p->input_semantic_index[ind] = semi;
-         }
-         else if (parse.FullToken.FullDeclaration.Declaration.File
-             == TGSI_FILE_OUTPUT) {
-            /* save output register info for use in get_result_vector() */
-            uint ind, sem, semi;
-            ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
-            sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
-            semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
-            /*debug_printf("FS Output DECL [%u] sem %u\n", ind, sem);*/
-            p->output_semantic_name[ind] = sem;
-            p->output_semantic_index[ind] = semi;
-         }
-         else if (parse.FullToken.FullDeclaration.Declaration.File
                   == TGSI_FILE_CONSTANT) {
             uint i;
             for (i = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
@@ -981,6 +959,7 @@ i915_translate_instructions(struct i915_fp_compile *p,
                  i <= parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
                  i++) {
                assert(i < I915_MAX_TEMPORARY);
+               /* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
                p->temp_flag |= (1 << i); /* mark temp as used */
             }
          }
@@ -1163,7 +1142,7 @@ i915_find_wpos_space(struct i915_fp_compile *p)
       i915_program_error(p, "No free texcoord for wpos value");
    }
 #else
-   if (p->shader->state.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
+   if (p->shader->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
       /* frag shader using the fragment position input */
 #if 0
       assert(0);
@@ -1184,7 +1163,7 @@ static void
 i915_fixup_depth_write(struct i915_fp_compile *p)
 {
    /* XXX assuming pos/depth is always in output[0] */
-   if (p->shader->state.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
+   if (p->shader->info.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
       const uint depth = UREG(REG_TYPE_OD, 0);
 
       i915_emit_arith(p,
index a35bdf941fc00d3f905042145ba98f6d0be71aa2..9df0e1254069026ea93efeb5a861d2c628ea35f5 100644 (file)
@@ -429,6 +429,8 @@ i915_create_fs_state(struct pipe_context *pipe,
 
    ifs->state = *templ;
 
+   tgsi_scan_shader(templ->tokens, &ifs->info);
+
    /* The shader's compiled to i915 instructions here */
    i915_translate_fragment_program(i915, ifs);
 
index 5cf70acdf3b031b68b35698bb437e2500fc60cbe..4daccec6e0c6ae172c95441480ab2b213d734370 100644 (file)
@@ -43,7 +43,7 @@
  */
 static void calculate_vertex_layout( struct i915_context *i915 )
 {
-   const struct pipe_shader_state *fs = &i915->fs->state;
+   const struct i915_fragment_shader *fs = i915->fs;
    const enum interp_mode colorInterp = i915->rasterizer->color_interp;
    struct vertex_info vinfo;
    boolean texCoords[8], colors[2], fog, needW;
@@ -57,18 +57,18 @@ static void calculate_vertex_layout( struct i915_context *i915 )
    /* Determine which fragment program inputs are needed.  Setup HW vertex
     * layout below, in the HW-specific attribute order.
     */
-   for (i = 0; i < fs->num_inputs; i++) {
-      switch (fs->input_semantic_name[i]) {
+   for (i = 0; i < fs->info.num_inputs; i++) {
+      switch (fs->info.input_semantic_name[i]) {
       case TGSI_SEMANTIC_POSITION:
          break;
       case TGSI_SEMANTIC_COLOR:
-         assert(fs->input_semantic_index[i] < 2);
-         colors[fs->input_semantic_index[i]] = TRUE;
+         assert(fs->info.input_semantic_index[i] < 2);
+         colors[fs->info.input_semantic_index[i]] = TRUE;
          break;
       case TGSI_SEMANTIC_GENERIC:
          /* usually a texcoord */
          {
-            const uint unit = fs->input_semantic_index[i];
+            const uint unit = fs->info.input_semantic_index[i];
             assert(unit < 8);
             texCoords[unit] = TRUE;
             needW = TRUE;