Just pass the visitor into is_copy_payload() and is_coalesce_candidate() instead of a register size and the virtual_grf_sizes array. Among other things, this makes the code more obvious because you don't have to figure out where src_size came from. --- src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp index c1b785b..0680086 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp @@ -64,9 +64,9 @@ is_nop_mov(const fs_inst *inst) } static bool -is_copy_payload(const fs_inst *inst, int src_size) +is_copy_payload(const fs_visitor *v, const fs_inst *inst) { - if (src_size != inst->sources) + if (v->virtual_grf_sizes[inst->src[0].reg] != inst->regs_written) return false; const int reg = inst->src[0].reg; @@ -83,7 +83,7 @@ is_copy_payload(const fs_inst *inst, int src_size) } static bool -is_coalesce_candidate(const fs_inst *inst, const int *virtual_grf_sizes) +is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst) { if ((inst->opcode != BRW_OPCODE_MOV && inst->opcode != SHADER_OPCODE_LOAD_PAYLOAD) || @@ -98,12 +98,12 @@ is_coalesce_candidate(const fs_inst *inst, const int *virtual_grf_sizes) return false; } - if (virtual_grf_sizes[inst->src[0].reg] > - virtual_grf_sizes[inst->dst.reg]) + if (v->virtual_grf_sizes[inst->src[0].reg] > + v->virtual_grf_sizes[inst->dst.reg]) return false; if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD) { - if (!is_copy_payload(inst, virtual_grf_sizes[inst->src[0].reg])) { + if (!is_copy_payload(v, inst)) { return false; } } @@ -171,7 +171,7 @@ fs_visitor::register_coalesce() int var_from[MAX_SAMPLER_MESSAGE_SIZE]; foreach_in_list(fs_inst, inst, &instructions) { - if (!is_coalesce_candidate(inst, virtual_grf_sizes)) + if (!is_coalesce_candidate(this, inst)) continue; if (is_nop_mov(inst)) { -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev