ac/nir/ps: add no_color_export option
authorQiang Yu <yuq825@gmail.com>
Wed, 29 Mar 2023 03:50:18 +0000 (11:50 +0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Apr 2023 03:27:26 +0000 (03:27 +0000)
For radv which always do ps lower but may use epilog or not.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22199>

src/amd/common/ac_nir.h
src/amd/common/ac_nir_lower_ps.c

index a8b14cc..e93790f 100644 (file)
@@ -321,6 +321,7 @@ typedef struct {
 
    /* Vulkan only */
    unsigned enable_mrt_output_nan_fixup;
+   bool no_color_export;
 } ac_nir_lower_ps_options;
 
 void
index 12558d8..0809bad 100644 (file)
@@ -234,7 +234,12 @@ gather_ps_store_output(nir_builder *b, nir_intrinsic_instr *intrin, lower_ps_sta
 
    s->output_types[slot] = type;
 
-   nir_instr_remove(&intrin->instr);
+   /* Keep color output instruction if not exported in nir. */
+   if (!s->options->no_color_export ||
+       (slot < FRAG_RESULT_DATA0 && slot != FRAG_RESULT_COLOR)) {
+      nir_instr_remove(&intrin->instr);
+   }
+
    return true;
 }
 
@@ -740,6 +745,10 @@ export_ps_outputs(nir_builder *b, lower_ps_state *s)
 
    emit_ps_mrtz_export(b, s);
 
+   /* When non-monolithic shader, RADV export mrtz in main part and export color in epilog. */
+   if (s->options->no_color_export)
+      return;
+
    unsigned first_color_export = s->exp_num;
 
    /* When dual src blend is enabled and we need both src0 and src1