Module: Mesa Branch: main Commit: 23010acc10a344297c1f5791487fb60e42d0bc3e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=23010acc10a344297c1f5791487fb60e42d0bc3e
Author: Alyssa Rosenzweig <[email protected]> Date: Wed May 17 19:01:50 2023 -0400 pan/mdg: Fix temp count calculation 1. Always calculate when asked. This is the sort of optimization that just introduces bugs. Like one I hit when shuffling register indices around with the register access changes. 2. Ask before using in RA. 3. Account for precoloured blend inputs. Small shader-db hit, didn't investigate too much. total instructions in shared programs: 1518017 -> 1518168 (<.01%) instructions in affected programs: 2895 -> 3046 (5.22%) helped: 0 HURT: 24 Instructions are HURT. total bundles in shared programs: 646756 -> 646782 (<.01%) bundles in affected programs: 1119 -> 1145 (2.32%) helped: 1 HURT: 19 Bundles are HURT. total quadwords in shared programs: 1133694 -> 1133728 (<.01%) quadwords in affected programs: 1736 -> 1770 (1.96%) helped: 0 HURT: 20 Quadwords are HURT. total registers in shared programs: 90596 -> 90612 (0.02%) registers in affected programs: 108 -> 124 (14.81%) helped: 0 HURT: 16 Registers are HURT. Signed-off-by: Alyssa Rosenzweig <[email protected]> Cc: mesa-stable Reviewed-by: Italo Nicola <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23769> --- src/panfrost/midgard/midgard_ra.c | 2 +- src/panfrost/midgard/mir.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index bae8e695327..1d3252627e3 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -519,7 +519,7 @@ allocate_registers(compiler_context *ctx, bool *spilled) int work_count = max_work_registers(ctx); /* No register allocation to do with no SSA */ - + mir_compute_temp_count(ctx); if (!ctx->temp_count) return NULL; diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 07cbfc89236..aebf037b0dd 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -484,15 +484,18 @@ mir_flip(midgard_instruction *ins) void mir_compute_temp_count(compiler_context *ctx) { - if (ctx->temp_count) - return; - - unsigned max_dest = 0; + unsigned max_index = 0; mir_foreach_instr_global(ctx, ins) { if (ins->dest < SSA_FIXED_MINIMUM) - max_dest = MAX2(max_dest, ins->dest + 1); + max_index = MAX2(max_index, ins->dest + 1); } - ctx->temp_count = max_dest; + if (ctx->blend_input != ~0) + max_index = MAX2(max_index, ctx->blend_input + 1); + + if (ctx->blend_src1 != ~0) + max_index = MAX2(max_index, ctx->blend_src1 + 1); + + ctx->temp_count = max_index; }
