Module: Mesa Branch: main Commit: b2a37b43047d738976c78bb79854bdc3c985cce1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2a37b43047d738976c78bb79854bdc3c985cce1
Author: Samuel Pitoiset <[email protected]> Date: Thu Nov 16 16:51:28 2023 +0100 ac/nir: add an option to skip MRTZ exports in ac_nir_lower_ps() On RDNA3, alpha to coverage needs to be exported through MRTZ when depth, stencil or samplemask are also exported. This option will allow us to export MRTZ from PS epilogs instead of the main FS. Signed-off-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26413> --- src/amd/common/ac_nir.h | 1 + src/amd/common/ac_nir_lower_ps.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/amd/common/ac_nir.h b/src/amd/common/ac_nir.h index 98aaa4419a5..1dc4c9920e5 100644 --- a/src/amd/common/ac_nir.h +++ b/src/amd/common/ac_nir.h @@ -320,6 +320,7 @@ typedef struct { /* Vulkan only */ unsigned enable_mrt_output_nan_fixup; bool no_color_export; + bool no_depth_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 41450aaa30d..d5e62a90622 100644 --- a/src/amd/common/ac_nir_lower_ps.c +++ b/src/amd/common/ac_nir_lower_ps.c @@ -217,10 +217,16 @@ gather_ps_store_output(nir_builder *b, nir_intrinsic_instr *intrin, lower_ps_sta s->output_types[slot] = type; - /* Keep color output instruction if not exported in nir. */ - if (!s->options->no_color_export || - (slot < FRAG_RESULT_DATA0 && slot != FRAG_RESULT_COLOR)) { + /* Keep output instruction if not exported in nir. */ + if (!s->options->no_color_export && !s->options->no_depth_export) { nir_instr_remove(&intrin->instr); + } else { + if (slot >= FRAG_RESULT_DATA0 && !s->options->no_color_export) { + nir_instr_remove(&intrin->instr); + } else if ((slot == FRAG_RESULT_DEPTH || slot == FRAG_RESULT_STENCIL || + slot == FRAG_RESULT_SAMPLE_MASK) && !s->options->no_depth_export) { + nir_instr_remove(&intrin->instr); + } } return true; @@ -755,9 +761,12 @@ export_ps_outputs(nir_builder *b, lower_ps_state *s) emit_ps_color_clamp_and_alpha_test(b, s); - emit_ps_mrtz_export(b, s); + if (!s->options->no_depth_export) + emit_ps_mrtz_export(b, s); - /* When non-monolithic shader, RADV export mrtz in main part and export color in epilog. */ + /* When non-monolithic shader, RADV export mrtz in main part (except on + * RDNA3 for alpha to coverage) and export color in epilog. + */ if (s->options->no_color_export) return;
