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 <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23480>
This commit is contained in:
Alyssa Rosenzweig
2023-05-25 13:22:49 -04:00
committed by Marge Bot
parent f514d49ae2
commit 989d6fd378

View File

@@ -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;
}