From 0d34df0e6cd3e8bbf3896dd21f4a7e43dc73680e Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Fri, 9 Dec 2022 12:31:56 +0100 Subject: [PATCH] ir3/freedreno: Find regs for FS inputs when printing info FS inputs are not directly loaded into regs, but require additional instruction to do so. So in order to print in which reg the input is loaded we have to scan the shader for the instruction which loads the input. Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/ir3/ir3_shader.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 43686944ff4..d663c02ec94 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -743,6 +743,33 @@ dump_const_state(struct ir3_shader_variant *so, FILE *out) } } +static uint8_t +find_input_reg_id(struct ir3_shader_variant *so, uint32_t input_idx) +{ + uint8_t reg = so->inputs[input_idx].regid; + if (so->type != MESA_SHADER_FRAGMENT || !so->ir || VALIDREG(reg)) + return reg; + + /* In FS we don't know into which register the input is loaded + * until the shader is scanned for the input load instructions. + */ + foreach_block (block, &so->ir->block_list) { + foreach_instr_safe (instr, &block->instr_list) { + 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) { + return instr->dsts[0]->num; + } + } + } + } + } + + return INVALID_REG; +} + void ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) { @@ -805,7 +832,8 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) fprintf(out, "; %s: inputs:", type); for (i = 0; i < so->inputs_count; i++) { - uint8_t regid = so->inputs[i].regid; + uint8_t regid = find_input_reg_id(so, i); + fprintf(out, " r%d.%c (%s slot=%d cm=%x,il=%u,b=%u)", (regid >> 2), "xyzw"[regid & 0x3], input_name(so, i), so -> inputs[i].slot, so->inputs[i].compmask, so->inputs[i].inloc, so->inputs[i].bary);