r600g: texture offsets for non-TXF instructions
authorGrigori Goronzy <greg@chown.ath.cx>
Wed, 2 Oct 2013 22:12:55 +0000 (00:12 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 4 Oct 2013 20:44:47 +0000 (22:44 +0200)
All texture instructions can use offsets, not just TXF. Offsets into
the literals array were wrong, too.

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/r600_shader.c

index 206db04f2b67b3be1c5a753f628c33c8870cfba9..d17d6707c639266c038b8b304f10747029c4b276 100644 (file)
@@ -3782,16 +3782,16 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                }
        }
 
-       if (inst->Instruction.Opcode == TGSI_OPCODE_TXF) {
-               /* get offset values */
-               if (inst->Texture.NumOffsets) {
-                       assert(inst->Texture.NumOffsets == 1);
-
-                       offset_x = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
-                       offset_y = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
-                       offset_z = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
-               }
-       } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
+       /* get offset values */
+       if (inst->Texture.NumOffsets) {
+               assert(inst->Texture.NumOffsets == 1);
+
+               offset_x = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
+               offset_y = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
+               offset_z = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
+       }
+
+       if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
                /* TGSI moves the sampler to src reg 3 for TXD */
                sampler_src_reg = 3;