radv: determine if MRTZ needs to be exported via PS epilogs

For GFX11 only.

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-29 15:43:15 +01:00 committed by Marge Bot
parent b2a37b4304
commit 5b01285cfb
4 changed files with 19 additions and 2 deletions

View file

@ -671,6 +671,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_pipeline_key
.enable_mrt_output_nan_fixup =
pipeline_key->ps.epilog.enable_mrt_output_nan_fixup && !stage->nir->info.internal,
.no_color_export = stage->info.has_epilog,
.no_depth_export = stage->info.ps.exports_mrtz_via_epilog,
.bc_optimize_for_persp = G_0286CC_PERSP_CENTER_ENA(stage->info.ps.spi_ps_input) &&
G_0286CC_PERSP_CENTROID_ENA(stage->info.ps.spi_ps_input),

View file

@ -1933,6 +1933,15 @@ radv_generate_graphics_pipeline_key(const struct radv_device *device, const stru
key.ps.epilog = radv_pipeline_generate_ps_epilog_key(device, state, disable_mrt_compaction);
if (device->physical_device->rad_info.gfx_level >= GFX11) {
/* On GFX11, alpha to coverage is exported via MRTZ when depth/stencil/samplemask are also
* exported. Though, when a PS epilog is needed and the MS state is NULL (with dynamic
* rendering), it's not possible to know the info at compile time and MRTZ needs to be
* exported in the epilog.
*/
key.ps.exports_mrtz_via_epilog = key.ps.has_epilog && !state->ms;
}
key.dynamic_patch_control_points = !!(pipeline->dynamic_states & RADV_DYNAMIC_PATCH_CONTROL_POINTS);
key.dynamic_rasterization_samples = !!(pipeline->dynamic_states & RADV_DYNAMIC_RASTERIZATION_SAMPLES) ||

View file

@ -134,6 +134,7 @@ struct radv_pipeline_key {
/* Used to export alpha through MRTZ for alpha-to-coverage (GFX11+). */
bool alpha_to_coverage_via_mrtz;
bool exports_mrtz_via_epilog;
bool has_epilog;
@ -373,6 +374,7 @@ struct radv_shader_info {
bool writes_stencil;
bool writes_sample_mask;
bool writes_mrt0_alpha;
bool exports_mrtz_via_epilog;
bool has_pcoord;
bool prim_id_input;
bool layer_input;

View file

@ -808,8 +808,13 @@ gather_shader_info_fs(const struct radv_device *device, const nir_shader *nir,
info->has_epilog = pipeline_key->ps.has_epilog && info->ps.colors_written;
info->ps.writes_mrt0_alpha = (pipeline_key->ps.alpha_to_coverage_via_mrtz && (info->ps.color0_written & 0x8)) &&
(info->ps.writes_z || info->ps.writes_stencil || info->ps.writes_sample_mask);
const bool export_alpha_and_mrtz =
(info->ps.color0_written & 0x8) && (info->ps.writes_z || info->ps.writes_stencil || info->ps.writes_sample_mask);
info->ps.exports_mrtz_via_epilog =
info->has_epilog && pipeline_key->ps.exports_mrtz_via_epilog && export_alpha_and_mrtz;
info->ps.writes_mrt0_alpha = pipeline_key->ps.alpha_to_coverage_via_mrtz && export_alpha_and_mrtz;
info->ps.mrt0_is_dual_src = pipeline_key->ps.epilog.mrt0_is_dual_src;