tgsi: fix regression in indexed const lookups
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_build.c
index 17886540cf79ba92baea68fafcd329be4beafa98..d272533d63c764b365317270cf983363f0aee398 100644 (file)
@@ -25,7 +25,7 @@
  * 
  **************************************************************************/
 
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
 #include "pipe/p_shader_tokens.h"
 #include "tgsi_build.h"
 #include "tgsi_parse.h"
@@ -139,8 +139,8 @@ tgsi_build_declaration(
 {
    struct tgsi_declaration declaration;
 
-   assert( file <= TGSI_FILE_IMMEDIATE );
-   assert( interpolate <= TGSI_INTERPOLATE_PERSPECTIVE );
+   assert( file < TGSI_FILE_COUNT );
+   assert( interpolate < TGSI_INTERPOLATE_COUNT );
 
    declaration = tgsi_default_declaration();
    declaration.File = file;
@@ -584,6 +584,7 @@ tgsi_build_full_instruction(
       *dst_register = tgsi_build_dst_register(
          reg->DstRegister.File,
          reg->DstRegister.WriteMask,
+         reg->DstRegister.Indirect,
          reg->DstRegister.Index,
          instruction,
          header );
@@ -631,6 +632,28 @@ tgsi_build_full_instruction(
             header );
          prev_token = (struct tgsi_token  *) dst_register_ext_modulate;
       }
+
+      if( reg->DstRegister.Indirect ) {
+         struct tgsi_src_register *ind;
+
+         if( maxsize <= size )
+            return 0;
+         ind = (struct tgsi_src_register *) &tokens[size];
+         size++;
+
+         *ind = tgsi_build_src_register(
+            reg->DstRegisterInd.File,
+            reg->DstRegisterInd.SwizzleX,
+            reg->DstRegisterInd.SwizzleY,
+            reg->DstRegisterInd.SwizzleZ,
+            reg->DstRegisterInd.SwizzleW,
+            reg->DstRegisterInd.Negate,
+            reg->DstRegisterInd.Indirect,
+            reg->DstRegisterInd.Dimension,
+            reg->DstRegisterInd.Index,
+            instruction,
+            header );
+      }
    }
 
    for( i = 0;  i < full_inst->Instruction.NumSrcRegs; i++ ) {
@@ -973,7 +996,7 @@ tgsi_build_src_register(
 {
    struct tgsi_src_register   src_register;
 
-   assert( file <= TGSI_FILE_IMMEDIATE );
+   assert( file < TGSI_FILE_COUNT );
    assert( swizzle_x <= TGSI_SWIZZLE_W );
    assert( swizzle_y <= TGSI_SWIZZLE_W );
    assert( swizzle_z <= TGSI_SWIZZLE_W );
@@ -1194,13 +1217,14 @@ struct tgsi_dst_register
 tgsi_build_dst_register(
    unsigned file,
    unsigned mask,
+   unsigned indirect,
    int index,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header )
 {
    struct tgsi_dst_register dst_register;
 
-   assert( file <= TGSI_FILE_IMMEDIATE );
+   assert( file < TGSI_FILE_COUNT );
    assert( mask <= TGSI_WRITEMASK_XYZW );
    assert( index >= -32768 && index <= 32767 );
 
@@ -1208,6 +1232,7 @@ tgsi_build_dst_register(
    dst_register.File = file;
    dst_register.WriteMask = mask;
    dst_register.Index = index;
+   dst_register.Indirect = indirect;
 
    instruction_grow( instruction, header );
 
@@ -1220,6 +1245,7 @@ tgsi_default_full_dst_register( void )
    struct tgsi_full_dst_register full_dst_register;
 
    full_dst_register.DstRegister = tgsi_default_dst_register();
+   full_dst_register.DstRegisterInd = tgsi_default_src_register();
    full_dst_register.DstRegisterExtConcode =
       tgsi_default_dst_register_ext_concode();
    full_dst_register.DstRegisterExtModulate =