From a4323b097942a073822fb19c235af95edc58d64a Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Tue, 24 May 2022 18:25:47 +1200 Subject: [PATCH] panfrost: Only write depth / stencil once if MRT is used We can't assume that RT0 will be written, so this has to be based on whether a combined store has already been emitted, not the location of the store. Emit a non-special combined_store intrinsic that only writes colour for the other RTs, as reordering stores breaks the Midgard compiler. Fixes: d37e901e35a ("pan/mdg: Add new depth store lowering") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6527 Part-of: --- src/panfrost/util/pan_lower_writeout.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/panfrost/util/pan_lower_writeout.c b/src/panfrost/util/pan_lower_writeout.c index ea8fb5f1a55..75d482f2b7b 100644 --- a/src/panfrost/util/pan_lower_writeout.c +++ b/src/panfrost/util/pan_lower_writeout.c @@ -173,7 +173,12 @@ pan_nir_lower_zs_store(nir_shader *nir) nir_builder_init(&b, function->impl); b.cursor = nir_after_block_before_jump(instr->block); - pan_nir_emit_combined_store(&b, intr, writeout | PAN_WRITEOUT_C, stores); + /* Trying to write depth twice results in the + * wrong blend shader being executed on + * Midgard */ + unsigned this_store = PAN_WRITEOUT_C | (replaced ? 0 : writeout); + + pan_nir_emit_combined_store(&b, intr, this_store, stores); nir_instr_remove(instr);