From cea39af2fbf109e85a50263fe2ea50f7d568b31a Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Mon, 3 Jun 2019 13:58:11 -0700 Subject: freedreno/ir3: Generalize ir3_shader_disasm() Use a helper function to get the sysval/attribute/varying/output name and make the disam debug output independent of shader stage. Reviewed-by: Rob Clark --- src/freedreno/ir3/ir3_shader.c | 88 ++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 34af4ff689e..952ac9e1b2f 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -316,6 +316,28 @@ static void dump_output(FILE *out, struct ir3_shader_variant *so, dump_reg(out, name, regid); } +static const char * +input_name(struct ir3_shader_variant *so, int i) +{ + if (so->inputs[i].sysval) { + return gl_system_value_name(so->inputs[i].slot); + } else if (so->type == MESA_SHADER_VERTEX) { + return gl_vert_attrib_name(so->inputs[i].slot); + } else { + return gl_varying_slot_name(so->inputs[i].slot); + } +} + +static const char * +output_name(struct ir3_shader_variant *so, int i) +{ + if (so->type == MESA_SHADER_FRAGMENT) { + return gl_frag_result_name(so->outputs[i].slot); + } else { + return gl_varying_slot_name(so->outputs[i].slot); + } +} + void ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) { @@ -364,53 +386,27 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) disasm_a3xx(bin, so->info.sizedwords, 0, out, ir->compiler->gpu_id); - switch (so->type) { - case MESA_SHADER_VERTEX: - fprintf(out, "; %s: outputs:", type); - for (i = 0; i < so->outputs_count; i++) { - uint8_t regid = so->outputs[i].regid; - fprintf(out, " r%d.%c (%s)", - (regid >> 2), "xyzw"[regid & 0x3], - gl_varying_slot_name(so->outputs[i].slot)); - } - fprintf(out, "\n"); - fprintf(out, "; %s: inputs:", type); - for (i = 0; i < so->inputs_count; i++) { - uint8_t regid = so->inputs[i].regid; - fprintf(out, " r%d.%c (cm=%x,il=%u,b=%u)", - (regid >> 2), "xyzw"[regid & 0x3], - so->inputs[i].compmask, - so->inputs[i].inloc, - so->inputs[i].bary); - } - fprintf(out, "\n"); - break; - case MESA_SHADER_FRAGMENT: - fprintf(out, "; %s: outputs:", type); - for (i = 0; i < so->outputs_count; i++) { - uint8_t regid = so->outputs[i].regid; - const char *reg_type = so->outputs[i].half ? "hr" : "r"; - fprintf(out, " %s%d.%c (%s)", - reg_type, (regid >> 2), "xyzw"[regid & 0x3], - gl_frag_result_name(so->outputs[i].slot)); - } - fprintf(out, "\n"); - fprintf(out, "; %s: inputs:", type); - for (i = 0; i < so->inputs_count; i++) { - uint8_t regid = so->inputs[i].regid; - fprintf(out, " r%d.%c (%s,cm=%x,il=%u,b=%u)", - (regid >> 2), "xyzw"[regid & 0x3], - gl_varying_slot_name(so->inputs[i].slot), - so->inputs[i].compmask, - so->inputs[i].inloc, - so->inputs[i].bary); - } - fprintf(out, "\n"); - break; - default: - /* TODO */ - break; + fprintf(out, "; %s: outputs:", type); + for (i = 0; i < so->outputs_count; i++) { + uint8_t regid = so->outputs[i].regid; + fprintf(out, " r%d.%c (%s)", + (regid >> 2), "xyzw"[regid & 0x3], + output_name(so, i)); + } + fprintf(out, "\n"); + + fprintf(out, "; %s: inputs:", type); + for (i = 0; i < so->inputs_count; i++) { + uint8_t regid = so->inputs[i].regid; + 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); } + fprintf(out, "\n"); /* print generic shader info: */ fprintf(out, "; %s prog %d/%d: %u instructions, %d half, %d full\n", -- cgit v1.2.3