From ebe40b15ea67bf38bc45fa8825d2502e6b33c09c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 2 Dec 2022 13:46:34 -0500 Subject: [PATCH] agx: Fix discard with MRT The exact semantics of sample_mask aren't quite clear to me yet, but executing multiple sample_mask instructions seems to raise a fault :| Fixes SuperTuxKart's advanced renderer. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 3 ++- src/asahi/compiler/agx_compiler.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index f39c00e186c..ab85e4b0280 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -455,13 +455,14 @@ agx_emit_local_store_pixel(agx_builder *b, nir_intrinsic_instr *instr) agx_writeout(b, 0x000C); } - if (b->shader->nir->info.fs.uses_discard) { + if (b->shader->nir->info.fs.uses_discard && !b->shader->did_sample_mask) { /* If the shader uses discard, the sample mask must be written by the * shader on all exeuction paths. If we've reached the end of the shader, * we are therefore still active and need to write a full sample mask. * TODO: interactions with MSAA and gl_SampleMask writes */ agx_sample_mask(b, agx_immediate(1)); + b->shader->did_sample_mask = true; } /* Compact the registers according to the mask */ diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index 3cb30ccc06d..9538c1e5b15 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -408,7 +408,7 @@ typedef struct { unsigned alloc; /* I don't really understand how writeout ops work yet */ - bool did_writeout; + bool did_writeout, did_sample_mask; /* Has r0l been zeroed yet due to control flow? */ bool any_cf;