}
if (inst->dst.file == GRF && inst->dst.reg == spill_reg_nr) {
- dst_reg spill_reg = inst->dst;
- inst->dst.reg = virtual_grf_alloc(1);
-
- /* We don't want a swizzle when reading from the source; read the
- * whole register and use spill_reg's writemask to select which
- * channels to write.
- */
- src_reg temp = src_reg(inst->dst);
- temp.swizzle = BRW_SWIZZLE_XYZW;
- emit_scratch_write(inst, temp, spill_offset);
+ emit_scratch_write(inst, spill_offset);
}
}
* @base_offset is measured in 32-byte units (the size of a register).
*/
void
-vec4_visitor::emit_scratch_write(vec4_instruction *inst,
- src_reg temp, int base_offset)
+vec4_visitor::emit_scratch_write(vec4_instruction *inst, int base_offset)
{
int reg_offset = base_offset + inst->dst.reg_offset;
src_reg index = get_scratch_offset(inst, inst->dst.reladdr, reg_offset);
+ /* Create a temporary register to store *inst's result in. */
+ src_reg temp = src_reg(this, glsl_type::vec4_type);
+ temp.type = inst->dst.type;
+
dst_reg dst = dst_reg(brw_writemask(brw_vec8_grf(0, 0),
inst->dst.writemask));
vec4_instruction *write = SCRATCH_WRITE(dst, temp, index);
write->ir = inst->ir;
write->annotation = inst->annotation;
inst->insert_after(write);
+
+ inst->dst.file = temp.file;
+ inst->dst.reg = temp.reg;
+ inst->dst.reg_offset = temp.reg_offset;
+ inst->dst.reladdr = NULL;
}
/**
current_annotation = inst->annotation;
if (inst->dst.file == GRF && scratch_loc[inst->dst.reg] != -1) {
- src_reg temp = src_reg(this, glsl_type::vec4_type);
-
- emit_scratch_write(inst, temp, scratch_loc[inst->dst.reg]);
-
- inst->dst.file = temp.file;
- inst->dst.reg = temp.reg;
- inst->dst.reg_offset = temp.reg_offset;
- inst->dst.reladdr = NULL;
+ emit_scratch_write(inst, scratch_loc[inst->dst.reg]);
}
for (int i = 0 ; i < 3; i++) {