From 35d6f4a3945b221d39a8d25aac21b8fb818f35a9 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 19 Apr 2024 22:00:50 -0400 Subject: [PATCH] agx: fix spilling inside sample loop Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 10 ++++++++++ src/asahi/compiler/agx_compiler.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 5779df4923e..ae580c3bc9c 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -2947,6 +2947,16 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl, agx_builder _b = agx_init_builder(ctx, agx_before_block(start_block)); agx_stack_adjust(&_b, stack_size); + /* If we're going to execute multiple times, make sure we clean up after + * ourselves, else the hardware faults. + */ + if (ctx->stage == MESA_SHADER_FRAGMENT && !ctx->is_preamble && + ctx->key->fs.inside_sample_loop) { + + _b = agx_init_builder(ctx, agx_after_block(agx_end_block(ctx))); + agx_stack_adjust(&_b, -stack_size); + } + if (ctx->is_preamble) out->preamble_scratch_size = stack_size; else diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index 6be93e4ff4e..475e47b1909 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -584,6 +584,14 @@ agx_start_block(agx_context *ctx) return first; } +static inline agx_block * +agx_end_block(agx_context *ctx) +{ + agx_block *last = list_last_entry(&ctx->blocks, agx_block, link); + assert(agx_num_successors(last) == 0); + return last; +} + void agx_block_add_successor(agx_block *block, agx_block *successor); /* Iterators for AGX IR */