From a358890667a024722c6efeadff203eb2bd9ea86a Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Thu, 5 Jan 2023 14:02:17 +0100 Subject: [PATCH] ir3/print: Consider the size of input when matching it to a reg First component of the input may never be read, so we have to find the first component of the input which is being read. Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/ir3/ir3_shader.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index d663c02ec94..f117bd067b2 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -750,6 +750,8 @@ find_input_reg_id(struct ir3_shader_variant *so, uint32_t input_idx) if (so->type != MESA_SHADER_FRAGMENT || !so->ir || VALIDREG(reg)) return reg; + reg = INVALID_REG; + /* In FS we don't know into which register the input is loaded * until the shader is scanned for the input load instructions. */ @@ -758,16 +760,27 @@ find_input_reg_id(struct ir3_shader_variant *so, uint32_t input_idx) if (instr->opc == OPC_FLAT_B || instr->opc == OPC_BARY_F || instr->opc == OPC_LDLV) { if (instr->srcs[0]->flags & IR3_REG_IMMED) { - unsigned inloc = instr->srcs[0]->uim_val; - if (inloc == so->inputs[input_idx].inloc) { + unsigned inloc = so->inputs[input_idx].inloc; + unsigned instr_inloc = instr->srcs[0]->uim_val; + unsigned size = util_bitcount(so->inputs[input_idx].compmask); + + if (instr_inloc == inloc) { return instr->dsts[0]->num; } + + if (instr_inloc > inloc && instr_inloc < (inloc + size)) { + reg = MIN2(reg, instr->dsts[0]->num); + } + + if (instr->dsts[0]->flags & IR3_REG_EI) { + return reg; + } } } } } - return INVALID_REG; + return reg; } void