From 2976548e4a6c84444e7e1a94264f1219edbb67f8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 7 Jan 2023 14:46:18 -0500 Subject: [PATCH] nir/gather_info: Handle store_zs_agx This acts as a depth/stencil write. The AGX compiler checks outputs_written to determine what conservative depth settings the driver needs. Nominally, this should work: the original store_output(FRAG_RESULT_DEPTH) intrinsic causes the DEPTH outputs_written bit to be set, so the metadata is still correct after lowering store_output to store_zs_agx. However, there are a handful of places that call nir_gather_info late, which *resets* the existing outputs_written value and regathers, causing Asahi to use the wrong conservative depth settings when shuffling NIR pass order and breaking gl_FragDepth. To fix, handle store_zs_agx conservatively when gathering info so we don't have to play games with the pass order or stashing info in a sideband. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_gather_info.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index c0a227f4181..075510c0e6a 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -870,6 +870,11 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, shader->info.uses_memory_barrier = true; break; + case nir_intrinsic_store_zs_agx: + shader->info.outputs_written |= BITFIELD64_BIT(FRAG_RESULT_DEPTH) | + BITFIELD64_BIT(FRAG_RESULT_STENCIL); + break; + default: shader->info.uses_bindless |= intrinsic_is_bindless(instr); if (nir_intrinsic_writes_external_memory(instr))