dPdx[c].set(NULL);
dPdy[c].set(NULL);
}
+ for (int n = 0; n < 4; ++n)
+ for (int c = 0; c < 3; ++c)
+ offset[n][c].set(NULL);
}
TexInstruction *
}
}
+ for (int n = 0; n < tex->tex.useOffsets; ++n)
+ for (int c = 0; c < 3; ++c)
+ tex->offset[n][c].set(offset[n][c]);
+
return tex;
}
bool derivAll;
int8_t useOffsets; // 0, 1, or 4 for textureGatherOffsets
- int8_t offset[4][3];
+ int8_t offset[3]; // only used on nv50
enum TexQuery query;
} tex;
ValueRef dPdx[3];
ValueRef dPdy[3];
+ ValueRef offset[4][3];
};
class CmpInstruction : public Instruction
// ?
}
- if (i->tex.useOffsets) {
+ if (i->tex.useOffsets == 1) {
switch (i->op) {
case OP_TXF: code[1] |= 0x200; break;
default: code[1] |= 0x800; break;
}
}
+ if (i->tex.useOffsets == 4)
+ code[1] |= 0x1000;
}
void
code[0] |= 0x08000000;
} else
if (i->tex.useOffsets) {
- code[1] |= (i->tex.offset[0][0] & 0xf) << 24;
- code[1] |= (i->tex.offset[0][1] & 0xf) << 20;
- code[1] |= (i->tex.offset[0][2] & 0xf) << 16;
+ code[1] |= (i->tex.offset[0] & 0xf) << 24;
+ code[1] |= (i->tex.offset[1] & 0xf) << 20;
+ code[1] |= (i->tex.offset[2] & 0xf) << 16;
}
code[0] |= (i->tex.mask & 0x3) << 25;
i->tex.target == TEX_TARGET_2D_MS_ARRAY)
code[1] |= 1 << 23;
- if (i->tex.useOffsets) // in vecSrc0.w
+ if (i->tex.useOffsets == 1)
code[1] |= 1 << 22;
+ if (i->tex.useOffsets == 4)
+ code[1] |= 1 << 23;
srcId(i, src1, 26);
}
if (tgsi.getOpcode() == TGSI_OPCODE_TG4 && !tgt.isShadow())
texi->tex.gatherComp = tgsi.getSrc(1).getValueU32(0, info);
+ texi->tex.useOffsets = tgsi.getNumTexOffsets();
for (s = 0; s < tgsi.getNumTexOffsets(); ++s) {
for (c = 0; c < 3; ++c) {
- texi->tex.offset[s][c] = tgsi.getTexOffset(s).getValueU32(c, info);
- if (texi->tex.offset[s][c])
- texi->tex.useOffsets = s + 1;
+ texi->offset[s][c].set(fetchSrc(tgsi.getTexOffset(s), c, NULL));
+ texi->offset[s][c].setInsn(texi);
}
}
setTexRS(texi, c, R, -1);
+ texi->tex.useOffsets = tgsi.getNumTexOffsets();
for (s = 0; s < tgsi.getNumTexOffsets(); ++s) {
for (c = 0; c < 3; ++c) {
- texi->tex.offset[s][c] = tgsi.getTexOffset(s).getValueU32(c, info);
- if (texi->tex.offset[s][c])
- texi->tex.useOffsets = s + 1;
+ texi->offset[s][c].set(fetchSrc(tgsi.getTexOffset(s), c, NULL));
+ texi->offset[s][c].setInsn(texi);
}
}
// texel offsets are 3 immediate fields in the instruction,
// nv50 cannot do textureGatherOffsets
assert(i->tex.useOffsets <= 1);
+ if (i->tex.useOffsets) {
+ for (int c = 0; c < 3; ++c) {
+ ImmediateValue val;
+ assert(i->offset[0][c].getImmediate(val));
+ i->tex.offset[c] = val.reg.data.u32;
+ i->offset[0][c].set(NULL);
+ }
+ }
return true;
}
// offset is last source (lod 1st, dc 2nd)
if (i->tex.useOffsets) {
- uint32_t value = 0;
int n, c;
int s = i->srcCount(0xff, true);
if (i->srcExists(s)) // move potential predicate out of the way
i->moveSources(s, 1);
+ if (i->tex.useOffsets == 4 && i->srcExists(s + 1))
+ i->moveSources(s + 1, 1);
if (i->op == OP_TXG) {
- assert(i->tex.useOffsets == 1);
- for (c = 0; c < 3; ++c)
- value |= (i->tex.offset[0][c] & 0xff) << (c * 8);
+ // Either there is 1 offset, which goes into the 2 low bytes of the
+ // first source, or there are 4 offsets, which go into 2 sources (8
+ // values, 1 byte each).
+ Value *offs[2] = {NULL, NULL};
+ for (n = 0; n < i->tex.useOffsets; n++) {
+ for (c = 0; c < 2; ++c) {
+ if ((n % 2) == 0 && c == 0)
+ offs[n / 2] = i->offset[n][c].get();
+ else
+ bld.mkOp3(OP_INSBF, TYPE_U32,
+ offs[n / 2],
+ i->offset[n][c].get(),
+ bld.mkImm(0x800 | ((n * 16 + c * 8) % 32)),
+ offs[n / 2]);
+ }
+ }
+ i->setSrc(s, offs[0]);
+ if (offs[1])
+ i->setSrc(s + 1, offs[1]);
} else {
- for (n = 0; n < i->tex.useOffsets; ++n)
- for (c = 0; c < 3; ++c)
- value |= (i->tex.offset[n][c] & 0xf) << (n * 12 + c * 4);
+ unsigned imm = 0;
+ assert(i->tex.useOffsets == 1);
+ for (c = 0; c < 3; ++c) {
+ ImmediateValue val;
+ assert(i->offset[0][c].getImmediate(val));
+ imm |= (val.reg.data.u32 & 0xf) << (c * 4);
+ }
+ i->setSrc(s, bld.loadImm(NULL, imm));
}
- i->setSrc(s, bld.loadImm(NULL, value));
}
if (chipset >= NVISA_GK104_CHIPSET) {