}
inst->base_mrf = base_mrf;
inst->mlen = mlen;
+ inst->header_present = true;
if (simd16) {
for (int i = 0; i < 4; i++) {
fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
int sampler)
{
- int mlen = 1; /* g0 header always present. */
- int base_mrf = 1;
+ int mlen = 0;
+ int base_mrf = 2;
int reg_width = c->dispatch_width / 8;
+ bool header_present = false;
+
+ if (ir->offset) {
+ /* The TXD offsets set up by the ir_texture visitor are in the
+ * m1 header, so we can't go headerless.
+ */
+ header_present = true;
+ mlen++;
+ base_mrf--;
+ }
for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
fs_inst *inst = emit(BRW_OPCODE_MOV,
mlen += ir->coordinate->type->vector_elements * reg_width;
if (ir->shadow_comparitor) {
- mlen = MAX2(mlen, 1 + 4 * reg_width);
+ mlen = MAX2(mlen, header_present + 4 * reg_width);
ir->shadow_comparitor->accept(this);
emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
break;
case ir_txb:
ir->lod_info.bias->accept(this);
- mlen = MAX2(mlen, 1 + 4 * reg_width);
+ mlen = MAX2(mlen, header_present + 4 * reg_width);
emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
mlen += reg_width;
break;
case ir_txl:
ir->lod_info.lod->accept(this);
- mlen = MAX2(mlen, 1 + 4 * reg_width);
+ mlen = MAX2(mlen, header_present + 4 * reg_width);
emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
mlen += reg_width;
}
inst->base_mrf = base_mrf;
inst->mlen = mlen;
+ inst->header_present = header_present;
if (mlen > 11) {
fail("Message length >11 disallowed by hardware\n");
/* If there's an offset, we already set up m1. To avoid the implied move,
* use the null register. Otherwise, we want an implied move from g0.
*/
- if (ir->offset != NULL)
+ if (ir->offset != NULL || !inst->header_present)
inst->src[0] = fs_reg(brw_null_reg());
else
inst->src[0] = fs_reg(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW));
rlen,
inst->mlen,
0,
- 1,
+ inst->header_present,
simd_mode);
}