int base_mrf = 2;
int reg_width = c->dispatch_width / 8;
bool header_present = false;
+ int offsets[3];
- if (ir->offset) {
+ if (ir->offset && ir->op != ir_txf) {
/* The offsets set up by the ir_texture visitor are in the
* m1 header, so we can't go headerless.
*/
mlen += reg_width;
break;
case ir_txf:
+ /* It appears that the ld instruction used for txf does its
+ * address bounds check before adding in the offset. To work
+ * around this, just add the integer offset to the integer texel
+ * coordinate, and don't put the offset in the header.
+ */
+ if (ir->offset) {
+ ir_constant *offset = ir->offset->as_constant();
+ offsets[0] = offset->value.i[0];
+ offsets[1] = offset->value.i[1];
+ offsets[2] = offset->value.i[2];
+ } else {
+ memset(offsets, 0, sizeof(offsets));
+ }
+
/* Unfortunately, the parameters for LD are intermixed: u, lod, v, r. */
- emit(BRW_OPCODE_MOV,
- fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D), coordinate);
+ emit(BRW_OPCODE_ADD,
+ fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D), coordinate, offsets[0]);
coordinate.reg_offset++;
mlen += reg_width;
mlen += reg_width;
for (int i = 1; i < ir->coordinate->type->vector_elements; i++) {
- emit(BRW_OPCODE_MOV,
- fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D), coordinate);
+ emit(BRW_OPCODE_ADD,
+ fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D), coordinate, offsets[i]);
coordinate.reg_offset++;
mlen += reg_width;
}
ir->coordinate->accept(this);
fs_reg coordinate = this->result;
- if (ir->offset != NULL) {
+ if (ir->offset != NULL && !(intel->gen == 7 && ir->op == ir_txf)) {
uint32_t offset_bits = brw_texture_offset(ir->offset->as_constant());
/* Explicitly set up the message header by copying g0 to msg reg m1. */