tgsi: Handle two-dimensional constants in text parser.
authorMichal Krol <michal@vmware.com>
Thu, 21 Jan 2010 19:02:17 +0000 (20:02 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 28 Jan 2010 13:07:38 +0000 (14:07 +0100)
src/gallium/auxiliary/tgsi/tgsi_build.c
src/gallium/auxiliary/tgsi/tgsi_build.h
src/gallium/auxiliary/tgsi/tgsi_text.c

index de9cbc863051f7d2495fe3f61cb9cd95865bfa33..e38b0be7ab5ad9cf579d90e9d3c36ee33e441e89 100644 (file)
@@ -103,6 +103,7 @@ tgsi_default_declaration( void )
    declaration.File = TGSI_FILE_NULL;
    declaration.UsageMask = TGSI_WRITEMASK_XYZW;
    declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT;
+   declaration.Dimension = 0;
    declaration.Semantic = 0;
    declaration.Centroid = 0;
    declaration.Invariant = 0;
@@ -116,6 +117,7 @@ tgsi_build_declaration(
    unsigned file,
    unsigned usage_mask,
    unsigned interpolate,
+   unsigned dimension,
    unsigned semantic,
    unsigned centroid,
    unsigned invariant,
@@ -130,6 +132,7 @@ tgsi_build_declaration(
    declaration.File = file;
    declaration.UsageMask = usage_mask;
    declaration.Interpolate = interpolate;
+   declaration.Dimension = dimension;
    declaration.Semantic = semantic;
    declaration.Centroid = centroid;
    declaration.Invariant = invariant;
@@ -183,6 +186,7 @@ tgsi_build_full_declaration(
       full_decl->Declaration.File,
       full_decl->Declaration.UsageMask,
       full_decl->Declaration.Interpolate,
+      full_decl->Declaration.Dimension,
       full_decl->Declaration.Semantic,
       full_decl->Declaration.Centroid,
       full_decl->Declaration.Invariant,
@@ -199,6 +203,20 @@ tgsi_build_full_declaration(
       declaration,
       header );
 
+   if (full_decl->Declaration.Dimension) {
+      struct tgsi_declaration_dimension *dd;
+
+      if (maxsize <= size) {
+         return 0;
+      }
+      dd = (struct tgsi_declaration_dimension *)&tokens[size];
+      size++;
+
+      *dd = tgsi_build_declaration_dimension(full_decl->Dim.Index2D,
+                                             declaration,
+                                             header);
+   }
+
    if( full_decl->Declaration.Semantic ) {
       struct tgsi_declaration_semantic *ds;
 
@@ -249,6 +267,34 @@ tgsi_build_declaration_range(
    return declaration_range;
 }
 
+struct tgsi_declaration_dimension
+tgsi_default_declaration_dimension(void)
+{
+   struct tgsi_declaration_dimension dd;
+
+   dd.Index2D = 0;
+   dd.Padding = 0;
+
+   return dd;
+}
+
+struct tgsi_declaration_dimension
+tgsi_build_declaration_dimension(unsigned index_2d,
+                                 struct tgsi_declaration *declaration,
+                                 struct tgsi_header *header)
+{
+   struct tgsi_declaration_dimension dd;
+
+   assert(index_2d <= 0xFFFF);
+
+   dd = tgsi_default_declaration_dimension();
+   dd.Index2D = index_2d;
+
+   declaration_grow(declaration, header);
+
+   return dd;
+}
+
 struct tgsi_declaration_semantic
 tgsi_default_declaration_semantic( void )
 {
index 9de2757fe40b9ecc579784a37d3af0f6d2c43c73..ebee4ce5f6ab1679e756506894e00d59b00274e0 100644 (file)
@@ -64,6 +64,7 @@ tgsi_build_declaration(
    unsigned file,
    unsigned usage_mask,
    unsigned interpolate,
+   unsigned dimension,
    unsigned semantic,
    unsigned centroid,
    unsigned invariant,
@@ -89,6 +90,14 @@ tgsi_build_declaration_range(
    struct tgsi_declaration *declaration,
    struct tgsi_header *header );
 
+struct tgsi_declaration_dimension
+tgsi_default_declaration_dimension(void);
+
+struct tgsi_declaration_dimension
+tgsi_build_declaration_dimension(unsigned index_2d,
+                                 struct tgsi_declaration *declaration,
+                                 struct tgsi_header *header);
+
 struct tgsi_declaration_semantic
 tgsi_default_declaration_semantic( void );
 
index 7fe5dad5ffb86d49b13281f091bef9958d7de815..f74b56bfb5f454154ade8530c06933dfbc569237 100644 (file)
@@ -553,7 +553,7 @@ parse_register_dcl_bracket(
       report_error( ctx, "Expected literal unsigned integer" );
       return FALSE;
    }
-   bracket->first = (int) uindex;
+   bracket->first = uindex;
 
    eat_opt_white( &ctx->cur );
 
@@ -617,10 +617,12 @@ parse_register_dcl(
        * input primitive. so we want to declare just
        * the index relevant to the semantics which is in
        * the second bracket */
-      if (ctx->processor == TGSI_PROCESSOR_GEOMETRY) {
+      if (ctx->processor == TGSI_PROCESSOR_GEOMETRY && *file == TGSI_FILE_INPUT) {
          brackets[0] = brackets[1];
+         *num_brackets = 1;
+      } else {
+         *num_brackets = 2;
       }
-      *num_brackets = 2;
    }
 
    return TRUE;
@@ -738,6 +740,13 @@ parse_src_operand(
       return FALSE;
 
    src->Register.File = file;
+   if (parsed_opt_brackets) {
+      src->Register.Dimension = 1;
+      src->Dimension.Indirect = 0;
+      src->Dimension.Dimension = 0;
+      src->Dimension.Index = bracket[0].index;
+      bracket[0] = bracket[1];
+   }
    src->Register.Index = bracket[0].index;
    if (bracket[0].ind_file != TGSI_FILE_NULL) {
       src->Register.Indirect = 1;
@@ -748,12 +757,6 @@ parse_src_operand(
       src->Indirect.SwizzleZ = bracket[0].ind_comp;
       src->Indirect.SwizzleW = bracket[0].ind_comp;
    }
-   if (parsed_opt_brackets) {
-      src->Register.Dimension = 1;
-      src->Dimension.Indirect = 0;
-      src->Dimension.Dimension = 0;
-      src->Dimension.Index = bracket[1].index;
-   }
 
    /* Parse optional swizzle.
     */
@@ -969,8 +972,17 @@ static boolean parse_declaration( struct translate_ctx *ctx )
    decl = tgsi_default_full_declaration();
    decl.Declaration.File = file;
    decl.Declaration.UsageMask = writemask;
-   decl.Range.First = brackets[0].first;
-   decl.Range.Last = brackets[0].last;
+
+   if (num_brackets == 1) {
+      decl.Range.First = brackets[0].first;
+      decl.Range.Last = brackets[0].last;
+   } else {
+      decl.Range.First = brackets[1].first;
+      decl.Range.Last = brackets[1].last;
+
+      decl.Declaration.Dimension = 1;
+      decl.Dim.Index2D = brackets[0].first;
+   }
 
    cur = ctx->cur;
    eat_opt_white( &cur );