Clean-up the TGSI_SEMANTIC tokens, introduce semantic indexes.
authorBrian <brian.paul@tungstengraphics.com>
Thu, 20 Sep 2007 20:47:22 +0000 (14:47 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 20 Sep 2007 20:47:22 +0000 (14:47 -0600)
Still need to produce decl instructions for vertex shaders...

13 files changed:
src/mesa/pipe/draw/draw_vertex_shader.c
src/mesa/pipe/i915simple/i915_fpc.h
src/mesa/pipe/i915simple/i915_fpc_translate.c
src/mesa/pipe/i915simple/i915_state_derived.c
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_state_derived.c
src/mesa/pipe/tgsi/exec/tgsi_build.c
src/mesa/pipe/tgsi/exec/tgsi_dump.c
src/mesa/pipe/tgsi/exec/tgsi_token.h
src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
src/mesa/state_tracker/st_atom_fs.c
src/mesa/state_tracker/st_atom_vs.c

index 6461e3e3ba82040bb2cbd56ad028415d2dd55a89..ef0399c46e5f87405871b20db3445ad8b254edf9 100644 (file)
@@ -94,7 +94,8 @@ run_vertex_program(struct draw_context *draw,
    const float *trans = draw->viewport.translate;
 
    assert(count <= 4);
-   assert(draw->vertex_shader.output_semantics[0] == TGSI_SEMANTIC_POSITION);
+   assert(draw->vertex_shader.output_semantic_name[0]
+          == TGSI_SEMANTIC_POSITION);
 
 #ifdef DEBUG
    memset( &machine, 0, sizeof( machine ) );
index 5c4f2f90e98452a20e55817faddac042d702ec8a..5fdc7ef27eafb70c0f8f0268acaebd41e052d1c6 100644 (file)
@@ -51,7 +51,8 @@ struct i915_fp_compile {
    uint declarations[I915_PROGRAM_SIZE];
    uint program[I915_PROGRAM_SIZE];
 
-   uint input_semantic[PIPE_MAX_SHADER_INPUTS];
+   uint input_semantic_name[PIPE_MAX_SHADER_INPUTS];
+   uint input_semantic_index[PIPE_MAX_SHADER_INPUTS];
 
    /** points into the i915->current.constants array: */
    float (*constants)[4];
index df8859bec82c348ad59c6d3f3b0cb8bb4ffa0e3f..6f78c72e046af1e25a821f5cae9ecc56945b73b3 100644 (file)
@@ -128,7 +128,7 @@ src_vector(struct i915_fp_compile *p,
            const struct tgsi_full_src_register *source)
 {
    uint index = source->SrcRegister.Index;
-   uint src, sem;
+   uint src, sem_name, sem_ind;
 
    switch (source->SrcRegister.File) {
    case TGSI_FILE_TEMPORARY:
@@ -152,10 +152,11 @@ src_vector(struct i915_fp_compile *p,
       /* use vertex format info to map a slot number to a VF attrib */
       assert(index < p->vertex_info->num_attribs);
 
-      sem = p->input_semantic[index];
+      sem_name = p->input_semantic_name[index];
+      sem_ind = p->input_semantic_index[index];
 
 #if 1
-      switch (sem) {
+      switch (sem_name) {
       case TGSI_SEMANTIC_POSITION:
          printf("SKIP SEM POS\n");
          /*
@@ -163,28 +164,23 @@ src_vector(struct i915_fp_compile *p,
          src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL);
          */
          break;
-      case TGSI_SEMANTIC_COLOR0:
-         src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
-         break;
-      case TGSI_SEMANTIC_COLOR1:
-         src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ);
-         src = swizzle(src, X, Y, Z, ONE);
+      case TGSI_SEMANTIC_COLOR:
+         if (sem_ind == 0) {
+            src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
+         }
+         else {
+            /* secondary color */
+            assert(sem_ind == 1);
+            src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ);
+            src = swizzle(src, X, Y, Z, ONE);
+         }
          break;
       case TGSI_SEMANTIC_FOG:
          src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W);
          src = swizzle(src, W, W, W, W);
          break;
-      case TGSI_SEMANTIC_TEX0:
-      case TGSI_SEMANTIC_TEX1:
-      case TGSI_SEMANTIC_TEX2:
-      case TGSI_SEMANTIC_TEX3:
-      case TGSI_SEMANTIC_TEX4:
-      case TGSI_SEMANTIC_TEX5:
-      case TGSI_SEMANTIC_TEX6:
-      case TGSI_SEMANTIC_TEX7:
-         src = i915_emit_decl(p, REG_TYPE_T,
-                              T_TEX0 + (sem - TGSI_SEMANTIC_TEX0),
-                              D0_CHANNEL_ALL);
+      case TGSI_SEMANTIC_TEXCOORD:
+         src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind, D0_CHANNEL_ALL);
          break;
       default:
          i915_program_error(p, "Bad source->Index");
@@ -895,11 +891,13 @@ i915_translate_instructions(struct i915_fp_compile *p,
          if (parse.FullToken.FullDeclaration.Declaration.File
              == TGSI_FILE_INPUT) {
             /* save input register info for use in src_vector() */
-            uint ind, sem;
+            uint ind, sem, semi;
             ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
             sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
+            semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
             /*printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
-            p->input_semantic[ind] = sem;
+            p->input_semantic_name[ind] = sem;
+            p->input_semantic_index[ind] = semi;
          }
          break;
 
@@ -1059,7 +1057,7 @@ i915_find_wpos_space(struct i915_fp_compile *p)
       i915_program_error(p, "No free texcoord for wpos value");
    }
 #else
-   if (p->shader->input_semantics[0] == TGSI_SEMANTIC_POSITION) {
+   if (p->shader->input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
       /* frag shader using the fragment position input */
 #if 0
       assert(0);
@@ -1079,8 +1077,8 @@ i915_find_wpos_space(struct i915_fp_compile *p)
 static void
 i915_fixup_depth_write(struct i915_fp_compile *p)
 {
-   /* XXX assuming depth is always in output[0] */
-   if (p->shader->output_semantics[0] == TGSI_SEMANTIC_DEPTH) {
+   /* XXX assuming pos/depth is always in output[0] */
+   if (p->shader->output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
       const uint depth = UREG(REG_TYPE_OD, 0);
 
       i915_emit_arith(p,
index 2a03650620a45e5a6186e760c265763908d7bfb9..e825971199f0cd57c75cb616d4930ed6890dfb90 100644 (file)
@@ -59,28 +59,24 @@ static void calculate_vertex_layout( struct i915_context *i915 )
    /* Note: we'll set the S4_VFMT_XYZ[W] bits below */
 
    for (i = 0; i < fs->num_inputs; i++) {
-      switch (fs->input_semantics[i]) {
+      switch (fs->input_semantic_name[i]) {
       case TGSI_SEMANTIC_POSITION:
          break;
-      case TGSI_SEMANTIC_COLOR0:
-         front0 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp);
-         vinfo->hwfmt[0] |= S4_VFMT_COLOR;
-         break;
-      case TGSI_SEMANTIC_COLOR1:
-         assert(0); /* untested */
-         front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp);
-         vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG;
+      case TGSI_SEMANTIC_COLOR:
+         if (fs->input_semantic_index[i] == 0) {
+            front0 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp);
+            vinfo->hwfmt[0] |= S4_VFMT_COLOR;
+         }
+         else {
+            assert(fs->input_semantic_index[i] == 1);
+            assert(0); /* untested */
+            front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp);
+            vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG;
+         }
          break;
-      case TGSI_SEMANTIC_TEX0:
-      case TGSI_SEMANTIC_TEX1:
-      case TGSI_SEMANTIC_TEX2:
-      case TGSI_SEMANTIC_TEX3:
-      case TGSI_SEMANTIC_TEX4:
-      case TGSI_SEMANTIC_TEX5:
-      case TGSI_SEMANTIC_TEX6:
-      case TGSI_SEMANTIC_TEX7:
+      case TGSI_SEMANTIC_TEXCOORD:
          {
-            const uint unit = fs->input_semantics[i] - TGSI_SEMANTIC_TEX0;
+            const uint unit = fs->input_semantic_index[i];
             uint hwtc;
             texCoords[unit] = TRUE;
             draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
index 6396d49b84425271ff3ee4339906cad106479d59..d67736c558ef7f71491258f4065043cbb2365d9e 100644 (file)
@@ -148,8 +148,12 @@ struct pipe_shader_state {
    /** These fields somewhat constitute the shader "signature" */
    ubyte num_inputs;
    ubyte num_outputs;
-   ubyte input_semantics[PIPE_MAX_SHADER_INPUTS];
-   ubyte output_semantics[PIPE_MAX_SHADER_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];
 };
 
 struct pipe_depth_stencil_state
index b51ab66cf31674090b15c29db73c960249391a92..66e5cc48f68e7ba7cbd8211edcd8aadbd9169e59 100644 (file)
@@ -65,7 +65,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
    draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
 
    for (i = 0; i < fs->num_inputs; i++) {
-      switch (fs->input_semantics[i]) {
+      switch (fs->input_semantic_name[i]) {
       case TGSI_SEMANTIC_POSITION:
          /* Need Z if depth test is enabled or the fragment program uses the
           * fragment position (XYZW).
@@ -73,13 +73,16 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
          softpipe->need_z = TRUE;
          softpipe->need_w = TRUE;
          break;
-      case TGSI_SEMANTIC_COLOR0:
-         front0 = draw_emit_vertex_attr(vinfo,
-                                        FORMAT_4F, colorInterp);
-         break;
-      case TGSI_SEMANTIC_COLOR1:
-         front1 = draw_emit_vertex_attr(vinfo,
-                                        FORMAT_4F, colorInterp);
+      case TGSI_SEMANTIC_COLOR:
+         if (fs->input_semantic_index[i] == 0) {
+            front0 = draw_emit_vertex_attr(vinfo,
+                                           FORMAT_4F, colorInterp);
+         }
+         else {
+            assert(fs->input_semantic_index[i] == 1);
+            front1 = draw_emit_vertex_attr(vinfo,
+                                           FORMAT_4F, colorInterp);
+         }
          break;
       case TGSI_SEMANTIC_FOG:
          draw_emit_vertex_attr(vinfo,
@@ -96,12 +99,13 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
 #endif
          softpipe->psize_slot = i;
          /*case TGSI_SEMANTIC_TEXCOORD:*/
-      case TGSI_SEMANTIC_TEX0:
+      case TGSI_SEMANTIC_TEXCOORD:
+         /* unit = fs->input_semantic_index[i] */
          draw_emit_vertex_attr(vinfo,
                                FORMAT_4F, INTERP_PERSPECTIVE);
          softpipe->need_w = TRUE;
          break;
-      case TGSI_SEMANTIC_OTHER:
+      case TGSI_SEMANTIC_GENERIC:
          draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
          softpipe->need_w = TRUE;
          break;
index 1320872c64d11753411c3049326d62b7cf24cdb7..78f648aae256ab492985e89d622d49bf9acfa667 100755 (executable)
@@ -309,7 +309,7 @@ tgsi_default_declaration_semantic( void )
 {
    struct tgsi_declaration_semantic ds;
 
-   ds.SemanticName = TGSI_SEMANTIC_DEPTH;
+   ds.SemanticName = TGSI_SEMANTIC_POSITION;
    ds.SemanticIndex = 0;
    ds.Padding = 0;
 
index 0a47ad2a8c1c614dc193d3da6662610a4e606d71..315354198a257e01d52907b13b8572605bd6bbae 100755 (executable)
@@ -201,28 +201,22 @@ static const char *TGSI_INTERPOLATES_SHORT[] =
 
 static const char *TGSI_SEMANTICS[] =
 {
-   "SEMANTIC_DEPTH",
-   "SEMANTIC_COLOR0",
-   "SEMANTIC_COLOR1",
-   "SEMANTIC_COLOR0B",
-   "SEMANTIC_COLOR1B",
    "SEMANTIC_POSITION",
+   "SEMANTIC_COLOR",
+   "SEMANTIC_BCOLOR",
    "SEMANTIC_FOG",
-   "SEMANTIC_OTHER,"
-   "SEMANTIC_TEX0",
+   "SEMANTIC_TEXCOORD",
+   "SEMANTIC_GENERIC,"
 };
 
 static const char *TGSI_SEMANTICS_SHORT[] =
 {
-   "DEPTH",
-   "COLOR0",
-   "COLOR1",
-   "COLOR0B",
-   "COLOR1B",
    "POSITION",
+   "COLOR",
+   "BCOLOR",
    "FOG",
-   "OTHER",
-   "TEX0"
+   "TEXCOORD",
+   "GENERIC",
 };
 
 static const char *TGSI_IMMS[] =
index a642ba131a46a8c66cf6ea9a7310e97194fb91cc..2d468b801e7f09eb6a3de72ea340c0f6ababc2e0 100644 (file)
@@ -103,23 +103,13 @@ struct tgsi_declaration_interpolation
    unsigned Padding       : 28;
 };
 
-#define TGSI_SEMANTIC_DEPTH    0
-#define TGSI_SEMANTIC_COLOR0   1
-#define TGSI_SEMANTIC_COLOR1   2
-#define TGSI_SEMANTIC_COLOR0B  3 /**< back-face primary color */
-#define TGSI_SEMANTIC_COLOR1B  4 /**< back-face secondary color */
-#define TGSI_SEMANTIC_POSITION 5
-#define TGSI_SEMANTIC_FOG      6
-#define TGSI_SEMANTIC_OTHER    7 /* XXX temp */
-#define TGSI_SEMANTIC_TEX0     8
-#define TGSI_SEMANTIC_TEX1     9
-#define TGSI_SEMANTIC_TEX2    10
-#define TGSI_SEMANTIC_TEX3    11
-#define TGSI_SEMANTIC_TEX4    12
-#define TGSI_SEMANTIC_TEX5    13
-#define TGSI_SEMANTIC_TEX6    14
-#define TGSI_SEMANTIC_TEX7    15
-#define TGSI_SEMANTIC_COUNT   16 /**< number of semantic values */
+#define TGSI_SEMANTIC_POSITION 0
+#define TGSI_SEMANTIC_COLOR    1
+#define TGSI_SEMANTIC_BCOLOR   2 /**< back-face color */
+#define TGSI_SEMANTIC_FOG      3
+#define TGSI_SEMANTIC_TEXCOORD 4
+#define TGSI_SEMANTIC_GENERIC  5
+#define TGSI_SEMANTIC_COUNT    6 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
index 115c5d1eb026b311f52d5152cd3ca9e05ef47a42..c7b62c9b848f494338fdb32e053c129abce8594d 100644 (file)
@@ -473,7 +473,8 @@ make_frag_input_decl(
    GLuint index,\r
    GLuint interpolate,\r
    GLuint usage_mask,\r
-   GLuint semantic_name )\r
+   GLuint semantic_name,\r
+   GLuint semantic_index )\r
 {\r
    struct tgsi_full_declaration decl;\r
 \r
@@ -486,6 +487,7 @@ make_frag_input_decl(
    decl.u.DeclarationRange.First = index;\r
    decl.u.DeclarationRange.Last = index;\r
    decl.Semantic.SemanticName = semantic_name;\r
+   decl.Semantic.SemanticIndex = semantic_index;\r
    decl.Interpolation.Interpolate = interpolate;\r
 \r
    return decl;\r
@@ -495,6 +497,7 @@ static struct tgsi_full_declaration
 make_frag_output_decl(\r
    GLuint index,\r
    GLuint semantic_name,\r
+   GLuint semantic_index,\r
    GLuint usage_mask )\r
 {\r
    struct tgsi_full_declaration decl;\r
@@ -507,7 +510,7 @@ make_frag_output_decl(
    decl.u.DeclarationRange.First = index;\r
    decl.u.DeclarationRange.Last = index;\r
    decl.Semantic.SemanticName = semantic_name;\r
-   decl.Semantic.SemanticIndex = 0;\r
+   decl.Semantic.SemanticIndex = semantic_index;\r
 \r
    return decl;\r
 }\r
@@ -528,7 +531,8 @@ tgsi_mesa_compile_fp_program(
    const struct gl_fragment_program *program,\r
    GLuint numInputs,\r
    const GLuint inputMapping[],\r
-   const ubyte inputSemantic[],\r
+   const ubyte inputSemanticName[],\r
+   const ubyte inputSemanticIndex[],\r
    const GLuint interpMode[],\r
    const GLuint outputMapping[],\r
    struct tgsi_token *tokens,\r
@@ -553,13 +557,13 @@ tgsi_mesa_compile_fp_program(
    ti = 3;\r
 \r
    for (i = 0; i < numInputs; i++) {\r
-      switch (inputSemantic[i]) {\r
+      switch (inputSemanticName[i]) {\r
       case TGSI_SEMANTIC_POSITION:\r
          /* Fragment XY pos */\r
          fulldecl = make_frag_input_decl(i,\r
                                          TGSI_INTERPOLATE_CONSTANT,\r
                                          TGSI_WRITEMASK_XY,\r
-                                         TGSI_SEMANTIC_POSITION );\r
+                                         TGSI_SEMANTIC_POSITION, 0 );\r
          ti += tgsi_build_full_declaration(\r
                                            &fulldecl,\r
                                            &tokens[ti],\r
@@ -569,7 +573,7 @@ tgsi_mesa_compile_fp_program(
          fulldecl = make_frag_input_decl(i,\r
                                          TGSI_INTERPOLATE_LINEAR,\r
                                          TGSI_WRITEMASK_ZW,\r
-                                         TGSI_SEMANTIC_POSITION );\r
+                                         TGSI_SEMANTIC_POSITION, 0 );\r
          ti += tgsi_build_full_declaration(\r
                                            &fulldecl,\r
                                            &tokens[ti],\r
@@ -580,7 +584,8 @@ tgsi_mesa_compile_fp_program(
          fulldecl = make_frag_input_decl(i,\r
                                          interpMode[i],\r
                                          TGSI_WRITEMASK_XYZW,\r
-                                         inputSemantic[i] );\r
+                                         inputSemanticName[i],\r
+                                         inputSemanticIndex[i]);\r
          ti += tgsi_build_full_declaration(&fulldecl,\r
                                            &tokens[ti],\r
                                            header,\r
@@ -599,7 +604,7 @@ tgsi_mesa_compile_fp_program(
 \r
    fulldecl = make_frag_output_decl(\r
       0,\r
-      TGSI_SEMANTIC_DEPTH,\r
+      TGSI_SEMANTIC_POSITION, 0,  /* Z / Depth */\r
       TGSI_WRITEMASK_Z );\r
    ti += tgsi_build_full_declaration(\r
       &fulldecl,\r
@@ -610,7 +615,7 @@ tgsi_mesa_compile_fp_program(
    if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) {\r
       fulldecl = make_frag_output_decl(\r
          1,\r
-         TGSI_SEMANTIC_COLOR0,\r
+         TGSI_SEMANTIC_COLOR0,\r
          TGSI_WRITEMASK_XYZW );\r
       ti += tgsi_build_full_declaration(\r
          &fulldecl,\r
index d61d80bab0312a2e35b4bd2c7faaed9233302a1b..b40331981ebbfb1e83bf05f77e3695728908aa04 100644 (file)
@@ -12,7 +12,8 @@ tgsi_mesa_compile_fp_program(
    const struct gl_fragment_program *program,\r
    GLuint numInputs,\r
    const GLuint inputMapping[],\r
-   const ubyte inputSemantic[],\r
+   const ubyte inputSemanticName[],\r
+   const ubyte inputSemanticIndex[],\r
    const GLuint interpMode[],\r
    const GLuint outputMapping[],\r
    struct tgsi_token *tokens,\r
index 4d65035143b8df908b42b7deb15f219420195ede..8ee4f407c766fb9e66bff375d493b3dc21248082 100644 (file)
@@ -77,23 +77,41 @@ st_translate_fragment_shader(struct st_context *st,
 
          switch (i) {
          case FRAG_ATTRIB_WPOS:
-            fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_POSITION;
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_POSITION;
+            fs.input_semantic_index[fs.num_inputs] = 0;
             interpMode[fs.num_inputs] = TGSI_INTERPOLATE_CONSTANT;
             break;
          case FRAG_ATTRIB_COL0:
-            fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR0;
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            fs.input_semantic_index[fs.num_inputs] = 0;
             interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR;
             break;
          case FRAG_ATTRIB_COL1:
-            fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR1;
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            fs.input_semantic_index[fs.num_inputs] = 1;
             interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR;
             break;
+         case FRAG_ATTRIB_FOGC:
+            assert(0);
+            break;
          case FRAG_ATTRIB_TEX0:
-            fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_TEX0;
+         case FRAG_ATTRIB_TEX1:
+         case FRAG_ATTRIB_TEX2:
+         case FRAG_ATTRIB_TEX3:
+         case FRAG_ATTRIB_TEX4:
+         case FRAG_ATTRIB_TEX5:
+         case FRAG_ATTRIB_TEX6:
+         case FRAG_ATTRIB_TEX7:
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_TEXCOORD;
+            fs.input_semantic_index[fs.num_inputs] = i - FRAG_ATTRIB_TEX0;
             interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
+         case FRAG_ATTRIB_VAR0:
+            /* fall-through */
          default:
-            assert(0);
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
+            fs.input_semantic_index[fs.num_inputs] = i - FRAG_ATTRIB_VAR0;
+            interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE;
          }
 
          fs.num_inputs++;
@@ -107,11 +125,11 @@ st_translate_fragment_shader(struct st_context *st,
       if (stfp->Base.Base.OutputsWritten & (1 << i)) {
          switch (i) {
          case FRAG_RESULT_DEPR:
-            fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_DEPTH;
+            fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION;
             outputMapping[i] = fs.num_outputs;
             break;
          case FRAG_RESULT_COLR:
-            fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_COLOR0;
+            fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR;
             outputMapping[i] = fs.num_outputs;
             break;
          default:
@@ -126,7 +144,8 @@ st_translate_fragment_shader(struct st_context *st,
    tgsi_mesa_compile_fp_program( &stfp->Base,
                                  fs.num_inputs,
                                  inputMapping,
-                                 fs.input_semantics,
+                                 fs.input_semantic_name,
+                                 fs.input_semantic_index,
                                  interpMode,
                                  outputMapping,
                                  stfp->tokens, ST_FP_MAX_TOKENS );
index fcf99bf1c92e788f0e226973668471df0ee4b0d4..b09f2bece7743d2d59d583aca89e9e6ec390e435 100644 (file)
@@ -64,9 +64,8 @@ st_translate_vertex_shader(struct st_context *st,
    memset(&vs, 0, sizeof(vs));
 
    /*
-    * Determine how many inputs there are.
-    * Also, compute two look-up tables that map between Mesa VERT_ATTRIB_x
-    * values and TGSI generic input indexes.
+    * Determine number of inputs, the mappings between VERT_ATTRIB_x
+    * and TGSI generic input indexes, plus input attrib semantic info.
     */
    for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++) {
       if (stvp->Base.Base.InputsRead & (1 << i)) {
@@ -74,26 +73,57 @@ st_translate_vertex_shader(struct st_context *st,
          stvp->index_to_input[vs.num_inputs] = i;
          switch (i) {
          case VERT_ATTRIB_POS:
-            vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_POSITION;
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_POSITION;
+            vs.input_semantic_index[vs.num_inputs] = 0;
+            break;
+         case VERT_ATTRIB_WEIGHT:
+            /* fall-through */
+         case VERT_ATTRIB_NORMAL:
+            /* just label as a generic */
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC;
+            vs.input_semantic_index[vs.num_inputs] = 0;
             break;
          case VERT_ATTRIB_COLOR0:
-            vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0;
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            vs.input_semantic_index[vs.num_inputs] = 0;
             break;
          case VERT_ATTRIB_COLOR1:
-            vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1;
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            vs.input_semantic_index[vs.num_inputs] = 1;
             break;
          case VERT_ATTRIB_TEX0:
-            vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_TEX0;
+         case VERT_ATTRIB_TEX1:
+         case VERT_ATTRIB_TEX2:
+         case VERT_ATTRIB_TEX3:
+         case VERT_ATTRIB_TEX4:
+         case VERT_ATTRIB_TEX5:
+         case VERT_ATTRIB_TEX6:
+         case VERT_ATTRIB_TEX7:
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_TEXCOORD;
+            vs.input_semantic_index[vs.num_inputs] = 1 - VERT_ATTRIB_TEX0;
+            break;
+         case VERT_ATTRIB_GENERIC0:
+         case VERT_ATTRIB_GENERIC1:
+         case VERT_ATTRIB_GENERIC2:
+         case VERT_ATTRIB_GENERIC3:
+         case VERT_ATTRIB_GENERIC4:
+         case VERT_ATTRIB_GENERIC5:
+         case VERT_ATTRIB_GENERIC6:
+         case VERT_ATTRIB_GENERIC7:
+            assert(i < VERT_ATTRIB_MAX);
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC;
+            vs.input_semantic_index[vs.num_inputs] = 1 - VERT_ATTRIB_GENERIC0;
             break;
          default:
-            vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_OTHER;
+            assert(0);
          }
          vs.num_inputs++;
       }
    }
 
    /*
-    * Determine number of outputs and the register mapping.
+    * Determine number of outputs, the register mapping and
+    * the semantic information for each vertex output/result.
     */
    for (i = 0; i < VERT_RESULT_MAX; i++) {
       if (stvp->Base.Base.OutputsWritten & (1 << i)) {
@@ -102,23 +132,49 @@ st_translate_vertex_shader(struct st_context *st,
 
          switch (i) {
          case VERT_RESULT_HPOS:
-            vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_POSITION;
+            vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_POSITION;
+            vs.output_semantic_index[vs.num_inputs] = 0;
             break;
          case VERT_RESULT_COL0:
-            vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0;
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            vs.output_semantic_index[vs.num_inputs] = 0;
             break;
          case VERT_RESULT_COL1:
-            vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1;
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR;
+            vs.output_semantic_index[vs.num_inputs] = 1;
             break;
          case VERT_RESULT_BFC0:
-            vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0B;
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_BCOLOR;
+            vs.output_semantic_index[vs.num_inputs] = 0;
             break;
          case VERT_RESULT_BFC1:
-            vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1B;
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_BCOLOR;
+            vs.output_semantic_index[vs.num_inputs] = 1;
+            break;
+         case VERT_RESULT_FOGC:
+         case VERT_RESULT_PSIZ:
+         case VERT_RESULT_EDGE:
+            assert(0);
             break;
+         case VERT_RESULT_TEX0:
+         case VERT_RESULT_TEX1:
+         case VERT_RESULT_TEX2:
+         case VERT_RESULT_TEX3:
+         case VERT_RESULT_TEX4:
+         case VERT_RESULT_TEX5:
+         case VERT_RESULT_TEX6:
+         case VERT_RESULT_TEX7:
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_TEXCOORD;
+            vs.output_semantic_index[vs.num_inputs] = i - VERT_RESULT_TEX0;
+            break;
+         case VERT_RESULT_VAR0:
+            /* fall-through */
          default:
-            vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_OTHER;
+            assert(i - VERT_RESULT_VAR0 < MAX_VARYING);
+            vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC;
+            vs.output_semantic_index[vs.num_inputs] = i - VERT_RESULT_VAR0;
          }
+
          vs.num_outputs++;
       }
    }