From 781dcc8ef8e9119a8f31f26d0da8a44d0ca92dd5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 17 Mar 2024 16:31:38 -0400 Subject: [PATCH] agx: optimize out wait_pix in some cases noticed in prop driver asm Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 1a30997049d..efddb299b98 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1239,7 +1239,16 @@ agx_emit_intrinsic(agx_builder *b, nir_intrinsic_instr *instr) assert(stage == MESA_SHADER_FRAGMENT); b->shader->out->writes_sample_mask = true; - agx_wait_pix(b, 0x0001); + /* We need to wait_pix before running Z/S tests, but we don't need to + * wait_pix before merely discarding. Omit the wait_pix when the affected + * samples are unconditionally killed. + */ + bool no_tests = + nir_src_is_const(instr->src[1]) && nir_src_as_uint(instr->src[1]) == 0; + + if (!no_tests) + agx_wait_pix(b, 0x0001); + return agx_sample_mask(b, agx_src_index(&instr->src[0]), agx_src_index(&instr->src[1])); }