agx: remove spurious z/s writes in force early-z shaders

fixes crash in arb_shader_image_load_store-early-z

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
This commit is contained in:
Alyssa Rosenzweig 2023-11-27 16:30:43 -04:00
parent c43c90a5fa
commit 3987c8a35f
2 changed files with 12 additions and 3 deletions

View file

@ -13,7 +13,7 @@
#define BASE_S 2
static bool
lower_zs_emit(nir_block *block)
lower_zs_emit(nir_block *block, bool force_early_z)
{
nir_intrinsic_instr *zs_emit = NULL;
bool progress = false;
@ -31,6 +31,16 @@ lower_zs_emit(nir_block *block)
sem.location != FRAG_RESULT_STENCIL)
continue;
/* If early-Z is forced, z/s writes are a no-op (and will cause problems
* later in the compile). Piglit early-z tests this. Just remove the
* offending writes.
*/
if (force_early_z) {
nir_instr_remove(instr);
progress = true;
continue;
}
nir_builder b = nir_builder_at(nir_before_instr(instr));
nir_def *value = intr->src[0].ssa;
@ -117,7 +127,7 @@ agx_nir_lower_zs_emit(nir_shader *s)
bool progress = false;
nir_foreach_block(block, impl) {
progress |= lower_zs_emit(block);
progress |= lower_zs_emit(block, s->info.fs.early_fragment_tests);
}
if (progress) {

View file

@ -70,7 +70,6 @@ agx_nir_lower_frag_sidefx(nir_shader *s)
* incorrectly and then the side effects not kicking in.
*/
if (s->info.fs.early_fragment_tests) {
assert(!writes_zs && "incompatible");
nir_function_impl *impl = nir_shader_get_entrypoint(s);
nir_builder b = nir_builder_at(nir_before_impl(impl));
nir_sample_mask_agx(&b, nir_imm_intN_t(&b, ALL_SAMPLES, 16),