From 86944e063ad40cac0860bfd85a3cc4e9a9805aa3 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 1 Sep 2016 12:42:20 -0700 Subject: i965/fs: Replace fs_reg::reg_offset with fs_reg::offset expressed in bytes. The fs_reg::offset field in byte units introduced in this patch is a more straightforward alternative to the current register offset representation split between fs_reg::reg_offset and ::subreg_offset. The split representation makes it too easy to forget about one of the offsets while dealing with the other, which has led to multiple back-end bugs in the past. To make the matter worse the unit reg_offset was expressed in was rather inconsistent, for uniforms it would be expressed in either 4B or 16B units depending on the back-end, and for most other things it would be expressed in 32B units. This encodes reg_offset as a new offset field expressed consistently in byte units. Each rvalue reference of reg_offset in existing code like 'x = r.reg_offset' is rewritten to 'x = r.offset / reg_unit', and each lvalue reference like 'r.reg_offset = x' is rewritten to 'r.offset = r.offset % reg_unit + x * reg_unit'. Because the change affects a lot of places and is rather non-trivial to verify due to the inconsistent value of reg_unit, I've tried to avoid making any additional changes other than applying the rewrite rule above in order to keep the patch as simple as possible, sometimes at the cost of introducing obvious stupidity (e.g. algebraic expressions that could be simplified given some knowledge of the context) -- I'll clean those up later on in a second pass. Reviewed-by: Iago Toral Quiroga --- src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp') diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp index 518827b..09d0a4e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -341,9 +341,8 @@ region_contained_in(const fs_reg &src, unsigned regs_read, const fs_reg &dst, unsigned regs_written) { return src.file == dst.file && src.nr == dst.nr && - (src.reg_offset * REG_SIZE + src.subreg_offset >= - dst.reg_offset * REG_SIZE + dst.subreg_offset) && - src.reg_offset + regs_read <= dst.reg_offset + regs_written; + (src.offset + src.subreg_offset >= dst.offset + dst.subreg_offset) && + src.offset / REG_SIZE + regs_read <= dst.offset / REG_SIZE + regs_written; } bool @@ -462,8 +461,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) inst->saturate = inst->saturate || entry->saturate; /* Compute the offset of inst->src[arg] relative to entry->dst */ - const unsigned rel_offset = (inst->src[arg].reg_offset - - entry->dst.reg_offset) * REG_SIZE + + const unsigned rel_offset = inst->src[arg].offset - entry->dst.offset + inst->src[arg].subreg_offset; /* Compute the first component of the copy that the instruction is @@ -484,8 +482,8 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) */ const unsigned offset = suboffset + component * entry->src.stride * type_sz(entry->src.type) + - entry->src.reg_offset * reg_size + entry->src.subreg_offset; - inst->src[arg].reg_offset = offset / reg_size; + entry->src.offset + entry->src.subreg_offset; + inst->src[arg].offset = ROUND_DOWN_TO(offset, reg_size); inst->src[arg].subreg_offset = offset % reg_size; if (has_source_modifiers) { @@ -747,7 +745,7 @@ can_propagate_from(fs_inst *inst) inst->dst.file == VGRF && ((inst->src[0].file == VGRF && (inst->src[0].nr != inst->dst.nr || - inst->src[0].reg_offset != inst->dst.reg_offset)) || + inst->src[0].offset / REG_SIZE != inst->dst.offset / REG_SIZE)) || inst->src[0].file == ATTR || inst->src[0].file == UNIFORM || inst->src[0].file == IMM) && @@ -824,7 +822,7 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block, if (inst->src[i].file == VGRF) { acp_entry *entry = ralloc(copy_prop_ctx, acp_entry); entry->dst = inst->dst; - entry->dst.reg_offset += offset; + entry->dst.offset += offset * REG_SIZE; entry->src = inst->src[i]; entry->regs_written = regs_written; entry->regs_read = inst->regs_read(i); -- cgit v1.1