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:
case TGSI_OPCODE_TXD:
op = nir_texop_txd;
num_srcs = 3;
+ samp = 3;
break;
default:
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;
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));