From 2faa878f13b414d3c6d1e4c3c7642f8db52d9550 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 10 Apr 2015 14:19:22 -0400 Subject: [PATCH] gallium/ttn: fix TXD With TXD we also have the ddx/ddy sources (before the sampler). Signed-off-by: Rob Clark Reviewed-by: Eric Anholt --- src/gallium/auxiliary/nir/tgsi_to_nir.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index 9acf0b99220..0e871642b88 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -948,7 +948,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; + unsigned num_srcs, samp = 1; switch (tgsi_inst->Instruction.Opcode) { case TGSI_OPCODE_TEX: @@ -974,6 +974,7 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) case TGSI_OPCODE_TXD: op = nir_texop_txd; num_srcs = 3; + samp = 3; break; default: @@ -1016,8 +1017,8 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) if (instr->is_array) instr->coord_components++; - assert(tgsi_inst->Src[1].Register.File == TGSI_FILE_SAMPLER); - instr->sampler_index = tgsi_inst->Src[1].Register.Index; + assert(tgsi_inst->Src[samp].Register.File == TGSI_FILE_SAMPLER); + instr->sampler_index = tgsi_inst->Src[samp].Register.Index; unsigned src_number = 0; @@ -1045,6 +1046,19 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) src_number++; } + if (tgsi_inst->Instruction.Opcode == TGSI_OPCODE_TXD) { + instr->src[src_number].src = + nir_src_for_ssa(nir_swizzle(b, src[1], SWIZ(X, Y, Z, W), + instr->coord_components, false)); + instr->src[src_number].src_type = nir_tex_src_ddx; + src_number++; + instr->src[src_number].src = + nir_src_for_ssa(nir_swizzle(b, src[2], SWIZ(X, Y, Z, W), + instr->coord_components, false)); + instr->src[src_number].src_type = nir_tex_src_ddy; + src_number++; + } + if (instr->is_shadow) { if (instr->coord_components < 3) instr->src[src_number].src = nir_src_for_ssa(ttn_channel(b, src[0], Z)); -- 2.30.2