tgsi: Fix behaviour of dimension index.
authorMichal Krol <michal@vmware.com>
Mon, 18 Jan 2010 18:07:44 +0000 (19:07 +0100)
committerMichal Krol <michal@vmware.com>
Mon, 18 Jan 2010 18:13:49 +0000 (19:13 +0100)
The dimension index always addresses the second-dimension axis.

src/gallium/auxiliary/tgsi/tgsi_dump.c
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_sanity.c

index d7ff262f30a977822bf36c06b1eecb1a8e06b2f5..c254a7274f110fda8af0cb887468d4c8b19e2836 100644 (file)
@@ -219,8 +219,13 @@ _dump_register_src(
    struct dump_ctx *ctx,
    const struct tgsi_full_src_register *src )
 {
+   ENM(src->Register.File, file_names);
+   if (src->Register.Dimension) {
+      CHR('[');
+      SID(src->Dimension.Index);
+      CHR(']');
+   }
    if (src->Register.Indirect) {
-      ENM( src->Register.File, file_names );
       CHR( '[' );
       ENM( src->Indirect.File, file_names );
       CHR( '[' );
@@ -234,16 +239,10 @@ _dump_register_src(
       }
       CHR( ']' );
    } else {
-      ENM( src->Register.File, file_names );
       CHR( '[' );
       SID( src->Register.Index );
       CHR( ']' );
    }
-   if (src->Register.Dimension) {
-      CHR( '[' );
-      SID( src->Dimension.Index );
-      CHR( ']' );
-   }
 }
 
 static void
index 118a638ab48e078dc25c11db239f77c245a7f8f3..83646b73c1ee3d12735611a1463e89f5ebfaa031 100644 (file)
@@ -1129,11 +1129,14 @@ fetch_source(const struct tgsi_exec_machine *mach,
     * subscript to a register file. Effectively it means that
     * the register file is actually a 2D array of registers.
     *
-    *    file[1][3] == file[1*sizeof(file[1])+3],
+    *    file[3][1] == file[3*sizeof(file[1])+1],
     *    where:
     *       [3] = Dimension.Index
     */
    if (reg->Register.Dimension) {
+      int array_size;
+      union tgsi_exec_channel dim_index;
+
       /* The size of the first-order array depends on the register file type.
        * We need to multiply the index to the first array to get an effective,
        * "flat" index that points to the beginning of the second-order array.
@@ -1141,32 +1144,27 @@ fetch_source(const struct tgsi_exec_machine *mach,
       switch (reg->Register.File) {
       case TGSI_FILE_INPUT:
       case TGSI_FILE_SYSTEM_VALUE:
-         index.i[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
-         index.i[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
-         index.i[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
-         index.i[3] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
+         array_size = TGSI_EXEC_MAX_INPUT_ATTRIBS;
          break;
       case TGSI_FILE_CONSTANT:
-         index.i[0] *= TGSI_EXEC_MAX_CONST_BUFFER;
-         index.i[1] *= TGSI_EXEC_MAX_CONST_BUFFER;
-         index.i[2] *= TGSI_EXEC_MAX_CONST_BUFFER;
-         index.i[3] *= TGSI_EXEC_MAX_CONST_BUFFER;
+         array_size = TGSI_EXEC_MAX_CONST_BUFFER;
          break;
       default:
          assert( 0 );
+         array_size = 0;
       }
 
-      index.i[0] += reg->Dimension.Index;
-      index.i[1] += reg->Dimension.Index;
-      index.i[2] += reg->Dimension.Index;
-      index.i[3] += reg->Dimension.Index;
+      dim_index.i[0] =
+      dim_index.i[1] =
+      dim_index.i[2] =
+      dim_index.i[3] = reg->Dimension.Index;
 
       /* Again, the second subscript index can be addressed indirectly
        * identically to the first one.
        * Nothing stops us from indirectly addressing the indirect register,
        * but there is no need for that, so we won't exercise it.
        *
-       *    file[1][ind[4].y+3],
+       *    file[ind[4].y+3][1],
        *    where:
        *       ind = DimIndirect.File
        *       [4] = DimIndirect.Index
@@ -1191,20 +1189,25 @@ fetch_source(const struct tgsi_exec_machine *mach,
             &index2,
             &indir_index );
 
-         index.i[0] += indir_index.i[0];
-         index.i[1] += indir_index.i[1];
-         index.i[2] += indir_index.i[2];
-         index.i[3] += indir_index.i[3];
+         dim_index.i[0] += indir_index.i[0];
+         dim_index.i[1] += indir_index.i[1];
+         dim_index.i[2] += indir_index.i[2];
+         dim_index.i[3] += indir_index.i[3];
 
          /* for disabled execution channels, zero-out the index to
           * avoid using a potential garbage value.
           */
          for (i = 0; i < QUAD_SIZE; i++) {
             if ((execmask & (1 << i)) == 0)
-               index.i[i] = 0;
+               dim_index.i[i] = 0;
          }
       }
 
+      index.i[0] += dim_index.i[0] * array_size;
+      index.i[1] += dim_index.i[1] * array_size;
+      index.i[2] += dim_index.i[2] * array_size;
+      index.i[3] += dim_index.i[3] * array_size;
+
       /* If by any chance there was a need for a 3D array of register
        * files, we would have to check whether Dimension is followed
        * by a dimension register and continue the saga.
index 8bea457a63932faf1feedaeb83e73d6bf833506a..431c3ffb1420587b71c8c1ff61c0fafae88f1e69 100644 (file)
@@ -408,7 +408,7 @@ iter_declaration(
          uint vert;
          for (vert = 0; vert < ctx->implied_array_size; ++vert) {
             scan_register *reg = MALLOC(sizeof(scan_register));
-            fill_scan_register2d(reg, file, vert, i);
+            fill_scan_register2d(reg, file, i, vert);
             check_and_declare(ctx, reg);
          }
       } else {