Module: Mesa
Branch: main
Commit: 471418077a6fb5df0053b23ab3f3e7dd49b274b0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=471418077a6fb5df0053b23ab3f3e7dd49b274b0

Author: Qiang Yu <[email protected]>
Date:   Wed Mar 29 11:50:18 2023 +0800

ac/nir/ps: add no_color_export option

For radv which always do ps lower but may use epilog or not.

Reviewed-by: Timur Kristóf <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22199>

---

 src/amd/common/ac_nir.h          |  1 +
 src/amd/common/ac_nir_lower_ps.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_nir.h b/src/amd/common/ac_nir.h
index a8b14ccb39b..e93790fa083 100644
--- a/src/amd/common/ac_nir.h
+++ b/src/amd/common/ac_nir.h
@@ -321,6 +321,7 @@ typedef struct {
 
    /* Vulkan only */
    unsigned enable_mrt_output_nan_fixup;
+   bool no_color_export;
 } ac_nir_lower_ps_options;
 
 void
diff --git a/src/amd/common/ac_nir_lower_ps.c b/src/amd/common/ac_nir_lower_ps.c
index 12558d8c51c..0809badf08b 100644
--- a/src/amd/common/ac_nir_lower_ps.c
+++ b/src/amd/common/ac_nir_lower_ps.c
@@ -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

Reply via email to