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 <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26413>
This commit is contained in:
Samuel Pitoiset
2023-11-16 16:51:28 +01:00
committed by Marge Bot
parent 81eeb157f8
commit b2a37b4304
2 changed files with 15 additions and 5 deletions
+1
View File
@@ -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
+14 -5
View File
@@ -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;