agx: Lower discard late
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 7 Mar 2023 16:38:36 +0000 (11:38 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sat, 11 Mar 2023 23:34:56 +0000 (23:34 +0000)
Fixes regression with Dolphin's ubershaders.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21855>

src/asahi/compiler/agx_compile.c

index 83e13f8..151d80f 100644 (file)
@@ -2317,7 +2317,6 @@ agx_preprocess_nir(nir_shader *nir, bool support_lod_bias)
    NIR_PASS_V(nir, nir_lower_ssbo);
    if (nir->info.stage == MESA_SHADER_FRAGMENT) {
       NIR_PASS_V(nir, agx_nir_lower_frag_sidefx);
-      NIR_PASS_V(nir, agx_nir_lower_zs_emit);
 
       /* Interpolate varyings at fp16 and write to the tilebuffer at fp16. As an
        * exception, interpolate flat shaded at fp32. This works around a
@@ -2406,6 +2405,11 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
          out->depth_layout = layout;
    }
 
+   /* Late clip plane lowering created discards */
+   if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+      NIR_PASS_V(nir, agx_nir_lower_zs_emit);
+   }
+
    /* Late sysval lowering creates large loads. Load lowering creates unpacks */
    NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes,
               nir_var_mem_ssbo | nir_var_mem_constant |