summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/nir
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-04-11 11:35:29 -0400
committerRob Clark <[email protected]>2015-04-17 10:34:14 -0400
commitf44d836d7a26a7d7c4374cc9e1e8bdc96cd2db8e (patch)
treeefb59dc6fe8512143d5c0f903f74231f0f45768c /src/gallium/auxiliary/nir
parente050a19af895318aaf417919c6a8ecba2da53304 (diff)
gallium/ttn: add support for texture offsets
Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/nir')
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 9d988b06445..7312e54aefb 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -982,7 +982,7 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
struct tgsi_full_instruction *tgsi_inst = &c->token->FullInstruction;
nir_tex_instr *instr;
nir_texop op;
- unsigned num_srcs, samp = 1;
+ unsigned num_srcs, samp = 1, i;
switch (tgsi_inst->Instruction.Opcode) {
case TGSI_OPCODE_TEX:
@@ -1026,6 +1026,8 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
num_srcs++;
}
+ num_srcs += tgsi_inst->Texture.NumOffsets;
+
instr = nir_tex_instr_create(b->shader, num_srcs);
instr->op = op;
@@ -1103,6 +1105,31 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
src_number++;
}
+ for (i = 0; i < tgsi_inst->Texture.NumOffsets; i++) {
+ struct tgsi_texture_offset *tex_offset = &tgsi_inst->TexOffsets[i];
+ /* since TexOffset ins't using tgsi_full_src_register we get to
+ * do some extra gymnastics:
+ */
+ nir_alu_src src;
+
+ memset(&src, 0, sizeof(src));
+
+ src.src = ttn_src_for_file_and_index(c,
+ tex_offset->File,
+ tex_offset->Index,
+ NULL);
+
+ src.swizzle[0] = tex_offset->SwizzleX;
+ src.swizzle[1] = tex_offset->SwizzleY;
+ src.swizzle[2] = tex_offset->SwizzleZ;
+ src.swizzle[3] = TGSI_SWIZZLE_W;
+
+ instr->src[src_number].src_type = nir_tex_src_offset;
+ instr->src[src_number].src = nir_src_for_ssa(
+ nir_fmov_alu(b, src, nir_tex_instr_src_size(instr, src_number)));
+ src_number++;
+ }
+
assert(src_number == num_srcs);
nir_ssa_dest_init(&instr->instr, &instr->dest, 4, NULL);