From d608ca0363cd45195d33161386aed44278a27077 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 19 Nov 2022 17:37:25 -0500 Subject: [PATCH] agx: Handle vertex shaders that use <= 8 halfregs r5 and r6 are always getting lowered. Will prevent a regression with VBO lowering on a shader which has stride=0 and hence gets the vertex ID read optimized out with NIR: dEQP-GLES2.functional.draw.random.50 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_register_allocate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index a2fbc07065d..cb3cb057494 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -423,6 +423,12 @@ agx_ra(agx_context *ctx) ctx->max_reg = MAX2(ctx->max_reg, ssa_to_reg[i] + ncomps[i] - 1); } + /* Vertex shaders preload the vertex/instance IDs (r5, r6) even if the shader + * don't use them. Account for that so the preload doesn't clobber GPRs. + */ + if (ctx->nir->info.stage == MESA_SHADER_VERTEX) + ctx->max_reg = MAX2(ctx->max_reg, 6 * 2); + agx_foreach_instr_global(ctx, ins) { agx_foreach_ssa_src(ins, s) { unsigned v = ssa_to_reg[ins->src[s].value];