tgsi: use separate structure for indirect address v2
authorChristian König <christian.koenig@amd.com>
Thu, 7 Mar 2013 14:02:31 +0000 (15:02 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 19 Mar 2013 12:38:32 +0000 (13:38 +0100)
To further improve the optimization of source and destination
indirect addressing we need the ability to store a reference
to the declaration of the addressed operands.

Since most of the fields in tgsi_src_register doesn't apply for
an indirect addressing operand replace it with a separate
tgsi_ind_register structure and so make room for extra information.

v2: rename Declaration to ArrayID, put the ArrayID into () instead of []

Signed-off-by: Christian König <christian.koenig@amd.com>
16 files changed:
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
src/gallium/auxiliary/tgsi/tgsi_build.c
src/gallium/auxiliary/tgsi/tgsi_dump.c
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_parse.c
src/gallium/auxiliary/tgsi/tgsi_parse.h
src/gallium/auxiliary/tgsi/tgsi_text.c
src/gallium/auxiliary/tgsi/tgsi_ureg.c
src/gallium/auxiliary/tgsi/tgsi_ureg.h
src/gallium/auxiliary/tgsi/tgsi_util.c
src/gallium/auxiliary/tgsi/tgsi_util.h
src/gallium/drivers/i915/i915_fpc.h
src/gallium/drivers/nv30/nvfx_vertprog.c
src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
src/gallium/drivers/r600/r600_llvm.c
src/gallium/include/pipe/p_shader_tokens.h

index 9fe87c40b630609530c5ca6bed58d03e490389a3..f157dc11d26c0888da39844fea447873e2a17fdd 100644 (file)
@@ -517,12 +517,12 @@ emit_mask_scatter(struct lp_build_tgsi_soa_context *bld,
 static LLVMValueRef
 get_indirect_index(struct lp_build_tgsi_soa_context *bld,
                    unsigned reg_file, unsigned reg_index,
-                   const struct tgsi_src_register *indirect_reg)
+                   const struct tgsi_ind_register *indirect_reg)
 {
    LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
    struct lp_build_context *uint_bld = &bld->bld_base.uint_bld;
    /* always use X component of address register */
-   unsigned swizzle = indirect_reg->SwizzleX;
+   unsigned swizzle = indirect_reg->Swizzle;
    LLVMValueRef base;
    LLVMValueRef rel;
    LLVMValueRef max_index;
index 33cbbd8ca656329c6ec5f095c32fd8ad4b0d9424..435d94a2103fd5b49fbc6d4ed972dac38b97e45d 100644 (file)
@@ -816,6 +816,43 @@ tgsi_build_src_register(
    return src_register;
 }
 
+static struct tgsi_ind_register
+tgsi_default_ind_register( void )
+{
+   struct tgsi_ind_register ind_register;
+
+   ind_register.File = TGSI_FILE_NULL;
+   ind_register.Swizzle = TGSI_SWIZZLE_X;
+   ind_register.ArrayID = 0;
+
+   return ind_register;
+}
+
+static struct tgsi_ind_register
+tgsi_build_ind_register(
+   unsigned file,
+   unsigned swizzle,
+   unsigned arrayid,
+   int index,
+   struct tgsi_instruction *instruction,
+   struct tgsi_header *header )
+{
+   struct tgsi_ind_register   ind_register;
+
+   assert( file < TGSI_FILE_COUNT );
+   assert( swizzle <= TGSI_SWIZZLE_W );
+   assert( index >= -0x8000 && index <= 0x7FFF );
+
+   ind_register.File = file;
+   ind_register.Swizzle = swizzle;
+   ind_register.Index = index;
+   ind_register.ArrayID = arrayid;
+
+   instruction_grow( instruction, header );
+
+   return ind_register;
+}
+
 static struct tgsi_dimension
 tgsi_default_dimension( void )
 {
@@ -835,9 +872,9 @@ tgsi_default_full_src_register( void )
    struct tgsi_full_src_register full_src_register;
 
    full_src_register.Register = tgsi_default_src_register();
-   full_src_register.Indirect = tgsi_default_src_register();
+   full_src_register.Indirect = tgsi_default_ind_register();
    full_src_register.Dimension = tgsi_default_dimension();
-   full_src_register.DimIndirect = tgsi_default_src_register();
+   full_src_register.DimIndirect = tgsi_default_ind_register();
 
    return full_src_register;
 }
@@ -910,9 +947,9 @@ tgsi_default_full_dst_register( void )
    struct tgsi_full_dst_register full_dst_register;
 
    full_dst_register.Register = tgsi_default_dst_register();
-   full_dst_register.Indirect = tgsi_default_src_register();
+   full_dst_register.Indirect = tgsi_default_ind_register();
    full_dst_register.Dimension = tgsi_default_dimension();
-   full_dst_register.DimIndirect = tgsi_default_src_register();
+   full_dst_register.DimIndirect = tgsi_default_ind_register();
 
    return full_dst_register;
 }
@@ -1057,24 +1094,18 @@ tgsi_build_full_instruction(
          header );
 
       if( reg->Register.Indirect ) {
-         struct tgsi_src_register *ind;
+         struct tgsi_ind_register *ind;
 
          if( maxsize <= size )
             return 0;
-         ind = (struct tgsi_src_register *) &tokens[size];
+         ind = (struct tgsi_ind_register *) &tokens[size];
          size++;
 
-         *ind = tgsi_build_src_register(
+         *ind = tgsi_build_ind_register(
             reg->Indirect.File,
-            reg->Indirect.SwizzleX,
-            reg->Indirect.SwizzleY,
-            reg->Indirect.SwizzleZ,
-            reg->Indirect.SwizzleW,
-            reg->Indirect.Negate,
-            reg->Indirect.Absolute,
-            reg->Indirect.Indirect,
-            reg->Indirect.Dimension,
+            reg->Indirect.Swizzle,
             reg->Indirect.Index,
+            reg->Indirect.ArrayID,
             instruction,
             header );
       }
@@ -1096,24 +1127,18 @@ tgsi_build_full_instruction(
             header );
 
          if( reg->Dimension.Indirect ) {
-            struct tgsi_src_register *ind;
+            struct tgsi_ind_register *ind;
 
             if( maxsize <= size )
                return 0;
-            ind = (struct tgsi_src_register *) &tokens[size];
+            ind = (struct tgsi_ind_register *) &tokens[size];
             size++;
 
-            *ind = tgsi_build_src_register(
+            *ind = tgsi_build_ind_register(
                reg->DimIndirect.File,
-               reg->DimIndirect.SwizzleX,
-               reg->DimIndirect.SwizzleY,
-               reg->DimIndirect.SwizzleZ,
-               reg->DimIndirect.SwizzleW,
-               reg->DimIndirect.Negate,
-               reg->DimIndirect.Absolute,
-               reg->DimIndirect.Indirect,
-               reg->DimIndirect.Dimension,
+               reg->DimIndirect.Swizzle,
                reg->DimIndirect.Index,
+               reg->DimIndirect.ArrayID,
                instruction,
                header );
          }
@@ -1144,24 +1169,18 @@ tgsi_build_full_instruction(
          header );
 
       if( reg->Register.Indirect ) {
-         struct  tgsi_src_register *ind;
+         struct  tgsi_ind_register *ind;
 
          if( maxsize <= size )
             return 0;
-         ind = (struct tgsi_src_register *) &tokens[size];
+         ind = (struct tgsi_ind_register *) &tokens[size];
          size++;
 
-         *ind = tgsi_build_src_register(
+         *ind = tgsi_build_ind_register(
             reg->Indirect.File,
-            reg->Indirect.SwizzleX,
-            reg->Indirect.SwizzleY,
-            reg->Indirect.SwizzleZ,
-            reg->Indirect.SwizzleW,
-            reg->Indirect.Negate,
-            reg->Indirect.Absolute,
-            reg->Indirect.Indirect,
-            reg->Indirect.Dimension,
+            reg->Indirect.Swizzle,
             reg->Indirect.Index,
+            reg->Indirect.ArrayID,
             instruction,
             header );
       }
@@ -1183,24 +1202,18 @@ tgsi_build_full_instruction(
             header );
 
          if( reg->Dimension.Indirect ) {
-            struct tgsi_src_register *ind;
+            struct tgsi_ind_register *ind;
 
             if( maxsize <= size )
                return 0;
-            ind = (struct tgsi_src_register *) &tokens[size];
+            ind = (struct tgsi_ind_register *) &tokens[size];
             size++;
 
-            *ind = tgsi_build_src_register(
+            *ind = tgsi_build_ind_register(
                reg->DimIndirect.File,
-               reg->DimIndirect.SwizzleX,
-               reg->DimIndirect.SwizzleY,
-               reg->DimIndirect.SwizzleZ,
-               reg->DimIndirect.SwizzleW,
-               reg->DimIndirect.Negate,
-               reg->DimIndirect.Absolute,
-               reg->DimIndirect.Indirect,
-               reg->DimIndirect.Dimension,
+               reg->DimIndirect.Swizzle,
                reg->DimIndirect.Index,
+               reg->DimIndirect.ArrayID,
                instruction,
                header );
          }
index adca6af2a2912db6a0be5baf0fc7a6d523553279..d98f6c49366f95d952d173c4bd702723216b496c 100644 (file)
@@ -107,13 +107,18 @@ _dump_register_src(
          CHR( '[' );
          SID( src->DimIndirect.Index );
          TXT( "]." );
-         ENM( src->DimIndirect.SwizzleX, tgsi_swizzle_names );
+         ENM( src->DimIndirect.Swizzle, tgsi_swizzle_names );
          if (src->Dimension.Index != 0) {
             if (src->Dimension.Index > 0)
                CHR( '+' );
             SID( src->Dimension.Index );
          }
          CHR( ']' );
+         if (src->DimIndirect.ArrayID) {
+            CHR( '(' );
+            SID( src->DimIndirect.ArrayID );
+            CHR( ')' );
+         }
       } else {
          CHR('[');
          SID(src->Dimension.Index);
@@ -126,13 +131,18 @@ _dump_register_src(
       CHR( '[' );
       SID( src->Indirect.Index );
       TXT( "]." );
-      ENM( src->Indirect.SwizzleX, tgsi_swizzle_names );
+      ENM( src->Indirect.Swizzle, tgsi_swizzle_names );
       if (src->Register.Index != 0) {
          if (src->Register.Index > 0)
             CHR( '+' );
          SID( src->Register.Index );
       }
       CHR( ']' );
+      if (src->Indirect.ArrayID) {
+         CHR( '(' );
+         SID( src->Indirect.ArrayID );
+         CHR( ')' );
+      }
    } else {
       CHR( '[' );
       SID( src->Register.Index );
@@ -154,13 +164,18 @@ _dump_register_dst(
          CHR( '[' );
          SID( dst->DimIndirect.Index );
          TXT( "]." );
-         ENM( dst->DimIndirect.SwizzleX, tgsi_swizzle_names );
+         ENM( dst->DimIndirect.Swizzle, tgsi_swizzle_names );
          if (dst->Dimension.Index != 0) {
             if (dst->Dimension.Index > 0)
                CHR( '+' );
             SID( dst->Dimension.Index );
          }
          CHR( ']' );
+         if (dst->DimIndirect.ArrayID) {
+            CHR( '(' );
+            SID( dst->DimIndirect.ArrayID );
+            CHR( ')' );
+         }
       } else {
          CHR('[');
          SID(dst->Dimension.Index);
@@ -173,13 +188,18 @@ _dump_register_dst(
       CHR( '[' );
       SID( dst->Indirect.Index );
       TXT( "]." );
-      ENM( dst->Indirect.SwizzleX, tgsi_swizzle_names );
+      ENM( dst->Indirect.Swizzle, tgsi_swizzle_names );
       if (dst->Register.Index != 0) {
          if (dst->Register.Index > 0)
             CHR( '+' );
          SID( dst->Register.Index );
       }
       CHR( ']' );
+      if (dst->Indirect.ArrayID) {
+         CHR( '(' );
+         SID( dst->Indirect.ArrayID );
+         CHR( ')' );
+      }
    } else {
       CHR( '[' );
       SID( dst->Register.Index );
index 1af239507d4fb5cd5ddb6f7f7f4bac6d35b79043..8579d8a57eb143790e6639529def6e5fd765e82e 100644 (file)
@@ -1193,7 +1193,7 @@ fetch_source(const struct tgsi_exec_machine *mach,
       index2.i[2] =
       index2.i[3] = reg->Indirect.Index;
       /* get current value of address register[swizzle] */
-      swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, TGSI_CHAN_X );
+      swizzle = reg->Indirect.Swizzle;
       fetch_src_file_channel(mach,
                              chan_index,
                              reg->Indirect.File,
@@ -1253,7 +1253,7 @@ fetch_source(const struct tgsi_exec_machine *mach,
          index2.i[2] =
          index2.i[3] = reg->DimIndirect.Index;
 
-         swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, TGSI_CHAN_X );
+         swizzle = reg->DimIndirect.Swizzle;
          fetch_src_file_channel(mach,
                                 chan_index,
                                 reg->DimIndirect.File,
@@ -1357,7 +1357,7 @@ store_dest(struct tgsi_exec_machine *mach,
       index.i[3] = reg->Indirect.Index;
 
       /* get current value of address register[swizzle] */
-      swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, TGSI_CHAN_X );
+      swizzle = reg->Indirect.Swizzle;
 
       /* fetch values from the address/indirection register */
       fetch_src_file_channel(mach,
@@ -1409,7 +1409,7 @@ store_dest(struct tgsi_exec_machine *mach,
          index2.i[2] =
          index2.i[3] = reg->DimIndirect.Index;
 
-         swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, TGSI_CHAN_X );
+         swizzle = reg->DimIndirect.Swizzle;
          fetch_src_file_channel(mach,
                                 chan_index,
                                 reg->DimIndirect.File,
index 29079ef2140c95dc1ccfcd4be91ed18d2b57bdc7..70c1cb223ee05276a392e5b3f23d15a33df1518d 100644 (file)
@@ -200,15 +200,9 @@ tgsi_parse_token(
 
          next_token( ctx, &inst->Dst[i].Register );
 
-         if( inst->Dst[i].Register.Indirect ) {
+         if( inst->Dst[i].Register.Indirect )
             next_token( ctx, &inst->Dst[i].Indirect );
 
-            /*
-             * No support for indirect or multi-dimensional addressing.
-             */
-            assert( !inst->Dst[i].Indirect.Dimension );
-            assert( !inst->Dst[i].Indirect.Indirect );
-         }
          if( inst->Dst[i].Register.Dimension ) {
             next_token( ctx, &inst->Dst[i].Dimension );
 
@@ -217,15 +211,8 @@ tgsi_parse_token(
              */
             assert( !inst->Dst[i].Dimension.Dimension );
 
-            if( inst->Dst[i].Dimension.Indirect ) {
+            if( inst->Dst[i].Dimension.Indirect )
                next_token( ctx, &inst->Dst[i].DimIndirect );
-
-               /*
-                * No support for indirect or multi-dimensional addressing.
-                */
-               assert( !inst->Dst[i].Indirect.Indirect );
-               assert( !inst->Dst[i].Indirect.Dimension );
-            }
          }
       }
 
@@ -235,16 +222,9 @@ tgsi_parse_token(
 
          next_token( ctx, &inst->Src[i].Register );
 
-         if( inst->Src[i].Register.Indirect ) {
+         if( inst->Src[i].Register.Indirect )
             next_token( ctx, &inst->Src[i].Indirect );
 
-            /*
-             * No support for indirect or multi-dimensional addressing.
-             */
-            assert( !inst->Src[i].Indirect.Indirect );
-            assert( !inst->Src[i].Indirect.Dimension );
-         }
-
          if( inst->Src[i].Register.Dimension ) {
             next_token( ctx, &inst->Src[i].Dimension );
 
@@ -253,15 +233,8 @@ tgsi_parse_token(
              */
             assert( !inst->Src[i].Dimension.Dimension );
 
-            if( inst->Src[i].Dimension.Indirect ) {
+            if( inst->Src[i].Dimension.Indirect )
                next_token( ctx, &inst->Src[i].DimIndirect );
-
-               /*
-               * No support for indirect or multi-dimensional addressing.
-               */
-               assert( !inst->Src[i].Indirect.Indirect );
-               assert( !inst->Src[i].Indirect.Dimension );
-            }
          }
       }
 
index ae40f13affcce836732233e9c28e629f5d69ead8..808f31bc3878b7142816987d82c7a43f6e95121c 100644 (file)
@@ -44,17 +44,17 @@ struct tgsi_full_header
 struct tgsi_full_dst_register
 {
    struct tgsi_dst_register               Register;
-   struct tgsi_src_register               Indirect;
+   struct tgsi_ind_register               Indirect;
    struct tgsi_dimension                  Dimension;
-   struct tgsi_src_register               DimIndirect;
+   struct tgsi_ind_register               DimIndirect;
 };
 
 struct tgsi_full_src_register
 {
    struct tgsi_src_register         Register;
-   struct tgsi_src_register         Indirect;
+   struct tgsi_ind_register         Indirect;
    struct tgsi_dimension            Dimension;
-   struct tgsi_src_register         DimIndirect;
+   struct tgsi_ind_register         DimIndirect;
 };
 
 struct tgsi_full_declaration
index 8a2a760ef595e3ad8e0a5494f607c579119d1ae6..6b97bee8b0f67178905e81c7ec1769dd255715c7 100644 (file)
@@ -441,6 +441,7 @@ struct parsed_bracket {
    uint ind_file;
    int ind_index;
    uint ind_comp;
+   uint ind_array;
 };
 
 
@@ -508,6 +509,20 @@ parse_register_bracket(
       return FALSE;
    }
    ctx->cur++;
+   if (*ctx->cur == '(') {
+      ctx->cur++;
+      eat_opt_white( &ctx->cur );
+      if (!parse_uint( &ctx->cur, &brackets->ind_array )) {
+         report_error( ctx, "Expected literal unsigned integer" );
+         return FALSE;
+      }
+      eat_opt_white( &ctx->cur );
+      if (*ctx->cur != ')') {
+         report_error( ctx, "Expected `)'" );
+         return FALSE;
+      }
+      ctx->cur++;
+   }
    return TRUE;
 }
 
@@ -711,10 +726,8 @@ parse_dst_operand(
       dst->Register.Indirect = 1;
       dst->Indirect.File = bracket[0].ind_file;
       dst->Indirect.Index = bracket[0].ind_index;
-      dst->Indirect.SwizzleX = bracket[0].ind_comp;
-      dst->Indirect.SwizzleY = bracket[0].ind_comp;
-      dst->Indirect.SwizzleZ = bracket[0].ind_comp;
-      dst->Indirect.SwizzleW = bracket[0].ind_comp;
+      dst->Indirect.Swizzle = bracket[0].ind_comp;
+      dst->Indirect.ArrayID = bracket[0].ind_array;
    }
    return TRUE;
 }
@@ -797,10 +810,8 @@ parse_src_operand(
       src->Register.Indirect = 1;
       src->Indirect.File = bracket[0].ind_file;
       src->Indirect.Index = bracket[0].ind_index;
-      src->Indirect.SwizzleX = bracket[0].ind_comp;
-      src->Indirect.SwizzleY = bracket[0].ind_comp;
-      src->Indirect.SwizzleZ = bracket[0].ind_comp;
-      src->Indirect.SwizzleW = bracket[0].ind_comp;
+      src->Indirect.Swizzle = bracket[0].ind_comp;
+      src->Indirect.ArrayID = bracket[0].ind_array;
    }
 
    /* Parse optional swizzle.
index 1e862cb2198e2b54b433c3aa7cbf21efd097ce9b..782f4495fa3b299261977e7673fd649f6435ffa4 100644 (file)
@@ -59,6 +59,7 @@ union tgsi_any_token {
    struct tgsi_instruction_texture insn_texture;
    struct tgsi_texture_offset insn_texture_offset;
    struct tgsi_src_register src;
+   struct tgsi_ind_register ind;
    struct tgsi_dimension dim;
    struct tgsi_dst_register dst;
    unsigned value;
@@ -267,6 +268,7 @@ ureg_dst_register( unsigned file,
    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
    dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = index;
+   dst.ArrayID = 0;
 
    return dst;
 }
@@ -597,8 +599,10 @@ struct ureg_dst ureg_DECL_array_temporary( struct ureg_program *ureg,
    /* and also at the end of the array */
    util_bitmask_set(ureg->decl_temps, ureg->nr_temps);
 
-   if (ureg->nr_array_temps < UREG_MAX_ARRAY_TEMPS)
+   if (ureg->nr_array_temps < UREG_MAX_ARRAY_TEMPS) {
       ureg->array_temps[ureg->nr_array_temps++] = i;
+      dst.ArrayID = ureg->nr_array_temps;
+   }
 
    return dst;
 }
@@ -881,12 +885,10 @@ ureg_emit_src( struct ureg_program *ureg,
    if (src.Indirect) {
       out[0].src.Indirect = 1;
       out[n].value = 0;
-      out[n].src.File = src.IndirectFile;
-      out[n].src.SwizzleX = src.IndirectSwizzle;
-      out[n].src.SwizzleY = src.IndirectSwizzle;
-      out[n].src.SwizzleZ = src.IndirectSwizzle;
-      out[n].src.SwizzleW = src.IndirectSwizzle;
-      out[n].src.Index = src.IndirectIndex;
+      out[n].ind.File = src.IndirectFile;
+      out[n].ind.Swizzle = src.IndirectSwizzle;
+      out[n].ind.Index = src.IndirectIndex;
+      out[n].ind.ArrayID = src.ArrayID;
       n++;
    }
 
@@ -899,12 +901,10 @@ ureg_emit_src( struct ureg_program *ureg,
          out[n].dim.Index = src.DimensionIndex;
          n++;
          out[n].value = 0;
-         out[n].src.File = src.DimIndFile;
-         out[n].src.SwizzleX = src.DimIndSwizzle;
-         out[n].src.SwizzleY = src.DimIndSwizzle;
-         out[n].src.SwizzleZ = src.DimIndSwizzle;
-         out[n].src.SwizzleW = src.DimIndSwizzle;
-         out[n].src.Index = src.DimIndIndex;
+         out[n].ind.File = src.DimIndFile;
+         out[n].ind.Swizzle = src.DimIndSwizzle;
+         out[n].ind.Index = src.DimIndIndex;
+         out[n].ind.ArrayID = src.ArrayID;
       } else {
          out[n].dim.Indirect = 0;
          out[n].dim.Index = src.DimensionIndex;
@@ -943,12 +943,10 @@ ureg_emit_dst( struct ureg_program *ureg,
    
    if (dst.Indirect) {
       out[n].value = 0;
-      out[n].src.File = TGSI_FILE_ADDRESS;
-      out[n].src.SwizzleX = dst.IndirectSwizzle;
-      out[n].src.SwizzleY = dst.IndirectSwizzle;
-      out[n].src.SwizzleZ = dst.IndirectSwizzle;
-      out[n].src.SwizzleW = dst.IndirectSwizzle;
-      out[n].src.Index = dst.IndirectIndex;
+      out[n].ind.File = TGSI_FILE_ADDRESS;
+      out[n].ind.Swizzle = dst.IndirectSwizzle;
+      out[n].ind.Index = dst.IndirectIndex;
+      out[n].ind.ArrayID = dst.ArrayID;
       n++;
    }
 
index cd140de6ba99fa0722e3bcf315be64780cda719a..be99ae0f048d406d016f7859a2dd7af35096c9b6 100644 (file)
@@ -62,6 +62,7 @@ struct ureg_src
    int      IndirectIndex    : 16; /* SINT */
    int      DimensionIndex   : 16; /* SINT */
    int      DimIndIndex      : 16; /* SINT */
+   unsigned ArrayID          : 10; /* UINT */
 };
 
 /* Very similar to a tgsi_dst_register, removing unsupported fields
@@ -84,6 +85,7 @@ struct ureg_dst
    int      Index           : 16; /* SINT */
    int      IndirectIndex   : 16; /* SINT */
    int      IndirectSwizzle : 2;  /* TGSI_SWIZZLE_ */
+   unsigned ArrayID         : 10; /* UINT */
 };
 
 struct pipe_context;
@@ -1129,6 +1131,7 @@ ureg_dst( struct ureg_src src )
    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
    dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = src.Index;
+   dst.ArrayID = src.ArrayID;
 
    return dst;
 }
@@ -1157,6 +1160,7 @@ ureg_src_register(unsigned file,
    src.DimIndFile = TGSI_FILE_NULL;
    src.DimIndIndex = 0;
    src.DimIndSwizzle = 0;
+   src.ArrayID = 0;
 
    return src;
 }
@@ -1184,6 +1188,7 @@ ureg_src( struct ureg_dst dst )
    src.DimIndFile = TGSI_FILE_NULL;
    src.DimIndIndex = 0;
    src.DimIndSwizzle = 0;
+   src.ArrayID = dst.ArrayID;
 
    return src;
 }
@@ -1208,6 +1213,7 @@ ureg_dst_undef( void )
    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
    dst.PredSwizzleW = TGSI_SWIZZLE_W;
    dst.Index     = 0;
+   dst.ArrayID = 0;
 
    return dst;
 }
@@ -1235,6 +1241,7 @@ ureg_src_undef( void )
    src.DimIndFile = TGSI_FILE_NULL;
    src.DimIndIndex = 0;
    src.DimIndSwizzle = 0;
+   src.ArrayID = 0;
 
    return src;
 }
index 8a5a8eab5aab9a48a5fd1318e55d3e9f39243a08..dfd32d7be4417a2519f57823f93551649492f713 100644 (file)
@@ -320,3 +320,21 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
 
    return usage_mask;
 }
+
+/**
+ * Convert a tgsi_ind_register into a tgsi_src_register
+ */
+struct tgsi_src_register
+tgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg)
+{
+   struct tgsi_src_register src = {};
+
+   src.File = reg->File;
+   src.Index = reg->Index;
+   src.SwizzleX = reg->Swizzle;
+   src.SwizzleY = reg->Swizzle;
+   src.SwizzleZ = reg->Swizzle;
+   src.SwizzleW = reg->Swizzle;
+
+   return src;
+}
index 04702ba9826bd3a6bb36dd55048046a8e77eddb5..d9f8859a3530bb74f5bd78de0610bd74e2c0227b 100644 (file)
@@ -76,6 +76,9 @@ unsigned
 tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
                               unsigned src_idx);
 
+struct tgsi_src_register
+tgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg);
+
 #if defined __cplusplus
 }
 #endif
index 9e4a7ea0e4abfc27dbbfd48c8a6613980bdc8fab..e915822f4a9753cd68b327baaf86d9cd314fc76a 100644 (file)
@@ -276,9 +276,9 @@ struct i915_full_dst_register
 {
    struct i915_dst_register               Register;
 /*
-   struct tgsi_src_register               Indirect;
+   struct tgsi_ind_register               Indirect;
    struct tgsi_dimension                  Dimension;
-   struct tgsi_src_register               DimIndirect;
+   struct tgsi_ind_register               DimIndirect;
 */
 };
 
@@ -286,9 +286,9 @@ struct i915_full_src_register
 {
    struct i915_src_register         Register;
 /*
-   struct tgsi_src_register         Indirect;
+   struct tgsi_ind_register         Indirect;
    struct tgsi_dimension            Dimension;
-   struct tgsi_src_register         DimIndirect;
+   struct tgsi_ind_register         DimIndirect;
 */
 };
 
index 827d518cb54bbfea696cee39892cf6f9f5396757..74dba38001cbc6427184c92cc126df7cf8fc84f8 100644 (file)
@@ -405,7 +405,7 @@ tgsi_src(struct nvfx_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
           fsrc->Register.File == TGSI_FILE_INPUT)) {
          src.indirect = 1;
          src.indirect_reg = fsrc->Indirect.Index;
-         src.indirect_swz = fsrc->Indirect.SwizzleX;
+         src.indirect_swz = fsrc->Indirect.Swizzle;
       } else {
          src.reg.index = 0;
          src.reg.type = -1;
index a3830ed3c2a9317a6c27ee1e767e1cda0f6e998e..613187c0a121ec0329143384a1a19b7347d12a46 100644 (file)
@@ -23,6 +23,7 @@
 extern "C" {
 #include "tgsi/tgsi_dump.h"
 #include "tgsi/tgsi_scan.h"
+#include "tgsi/tgsi_util.h"
 }
 
 #include <set>
@@ -55,6 +56,11 @@ public:
 
       SrcRegister(const struct tgsi_src_register& src) : reg(src), fsr(NULL) { }
 
+      SrcRegister(const struct tgsi_ind_register& ind)
+         : reg(tgsi_util_get_src_from_ind(&ind)),
+           fsr(NULL)
+      { }
+
       struct tgsi_src_register offsetToSrc(struct tgsi_texture_offset off)
       {
          struct tgsi_src_register reg;
index 042193c990b3c173fa5b7929402095f661380892..6e6edb77c66a0aed7ec958ae06d73b5f1675eaa0 100644 (file)
@@ -34,7 +34,7 @@ static LLVMValueRef llvm_fetch_const(
        };
        if (reg->Register.Indirect) {
                struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
-               LLVMValueRef index = LLVMBuildLoad(bld_base->base.gallivm->builder, bld->addr[reg->Indirect.Index][reg->Indirect.SwizzleX], "");
+               LLVMValueRef index = LLVMBuildLoad(bld_base->base.gallivm->builder, bld->addr[reg->Indirect.Index][reg->Indirect.Swizzle], "");
                offset[1] = LLVMBuildAdd(bld_base->base.gallivm->builder, offset[1], index, "");
        }
        unsigned ConstantAddressSpace = CONSTANT_BUFFER_0_ADDR_SPACE ;
index eac75e69e5df77e2e59298f617edbf445f422f9c..1ca46fd0206a02cccddfecaee5ca2f30277f4b41 100644 (file)
@@ -563,7 +563,7 @@ struct tgsi_instruction_predicate
  *
  * Index specifies the element number of a register in the register file.
  *
- * If Indirect is TRUE, Index should be offset by the X component of a source
+ * If Indirect is TRUE, Index should be offset by the X component of the indirect
  * register that follows. The register can be now fetched into local storage
  * for further processing.
  *
@@ -589,14 +589,26 @@ struct tgsi_src_register
 };
 
 /**
- * If tgsi_src_register::Modifier is TRUE, tgsi_src_register_modifier follows.
- * 
- * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
- * follows.
+ * If tgsi_src_register::Indirect is TRUE, tgsi_ind_register follows.
+ *
+ * File, Index and Swizzle are handled the same as in tgsi_src_register.
+ *
+ * If ArrayID is zero the whole register file might be is indirectly addressed,
+ * if not only the Declaration with this ArrayID is accessed by this operand.
  *
- * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
  */
 
+struct tgsi_ind_register
+{
+   unsigned File    : 4;  /* TGSI_FILE_ */
+   int      Index   : 16; /* SINT */
+   unsigned Swizzle : 2;  /* TGSI_SWIZZLE_ */
+   unsigned ArrayID : 10; /* UINT */
+};
+
+/**
+ * If tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
+ */
 
 struct tgsi_dimension
 {