From 989d6fd37887c963f730b7a9a28ec34f434dbf2c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 25 May 2023 13:22:49 -0400 Subject: [PATCH] agx: Enable tag writes when sample mask written Including indirectly via discard/demote. Fixes graphical artefacts in Chromium when API sample masks are hooked up, which will result in fragment programs that do not write colour/depth but do a lone sample mask write. These need tag writes enabled (according to a trace from Metal for a case constructed to test this scenario). Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 7d723068dd1..1962e1466d1 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -2404,8 +2404,10 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, out->writes_psiz = nir->info.outputs_written & BITFIELD_BIT(VARYING_SLOT_PSIZ); } else if (nir->info.stage == MESA_SHADER_FRAGMENT) { + /* This is refined after emitting the program */ out->tag_write_disable = !(nir->info.outputs_written >> FRAG_RESULT_DATA0); + out->disable_tri_merging = nir->info.fs.needs_all_helper_invocations || nir->info.fs.needs_quad_helper_invocations || nir->info.writes_memory; @@ -2481,4 +2483,8 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, unreachable("General functions not yet supported"); } } + + /* Writing the sample mask requires tag writes */ + if (nir->info.stage == MESA_SHADER_FRAGMENT) + out->tag_write_disable &= !out->writes_sample_mask; }