From f836d573e48c6c72d301b1633c49f4b3a571d198 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 19 Jan 2024 13:17:15 -0400 Subject: [PATCH] agx: only run early tests if needed if it'd be early anyway don't bother, speeds up dolphin with spec shaders Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_nir_lower_sample_mask.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/asahi/compiler/agx_nir_lower_sample_mask.c b/src/asahi/compiler/agx_nir_lower_sample_mask.c index 35fce826cac..e28bf606f05 100644 --- a/src/asahi/compiler/agx_nir_lower_sample_mask.c +++ b/src/asahi/compiler/agx_nir_lower_sample_mask.c @@ -206,8 +206,15 @@ bool agx_nir_lower_sample_mask(nir_shader *shader, unsigned nr_samples) { if (shader->info.fs.early_fragment_tests) { - /* run tests early */ - run_tests_at_start(shader); + /* run tests early, if we need testing */ + if (shader->info.fs.uses_discard || + (shader->info.outputs_written & + (BITFIELD64_BIT(FRAG_RESULT_STENCIL) | + BITFIELD64_BIT(FRAG_RESULT_DEPTH))) || + shader->info.writes_memory) { + + run_tests_at_start(shader); + } } else if (shader->info.fs.uses_discard) { /* sample_mask can't be used with zs_emit, so lower sample_mask to zs_emit. * We ignore depth/stencil writes with early fragment testing though.