From eb4a581e44bf9770fc2d30432914eff9da6802ee Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Tue, 30 Sep 2025 12:13:06 -0400 Subject: [PATCH] intel/isl: Fix QPitch of arrayed MCS From RENDER_SURFACE_STATE::AuxiliarySurfaceQPitch on BDW+, This field must be set to an integer multiple of the Surface Vertical Alignment Accomplish this by aligning the height of each MCS layer to main surface's vertical alignment. Prevents the following test group from failing on Xe2 when a future commit enables multi-layer fast-clears in anv: dEQP-VK.api.image_clearing.*. clear_color_attachment.multiple_layers. *_clamp_input_sample_count_* The main test I used to debug this: dEQP-VK.api.image_clearing.core. clear_color_attachment.multiple_layers. a8b8g8r8_unorm_pack32_64x11_clamp_input_sample_count_2 Backport-to: 25.3 Reviewed-by: Jianxun Zhang Part-of: --- src/intel/isl/isl.c | 9 ++++++++- src/intel/isl/isl_surface_state.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c index 79bde563ae4..9c7c923a831 100644 --- a/src/intel/isl/isl.c +++ b/src/intel/isl/isl.c @@ -3906,11 +3906,18 @@ isl_surf_get_mcs_surf(const struct isl_device *dev, UNREACHABLE("Invalid sample count"); } + /* isl_genX(surf_fill_state_s) will assert on us if the QPitch is not + * aligned by the main surface's vertical alignment. Align the height of + * the image so that the QPitch follows. + */ + const uint32_t aligned_height = isl_align(surf->logical_level0_px.height, + surf->image_alignment_el.height); + return isl_surf_init(dev, mcs_surf, .dim = ISL_SURF_DIM_2D, .format = mcs_format, .width = surf->logical_level0_px.width, - .height = surf->logical_level0_px.height, + .height = aligned_height, .depth = 1, .levels = 1, .array_len = surf->logical_level0_px.array_len, diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c index 936885f106d..068f98ff0f7 100644 --- a/src/intel/isl/isl_surface_state.c +++ b/src/intel/isl/isl_surface_state.c @@ -911,8 +911,15 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state, * doesn't expect our definition of the compression, it expects qpitch * in units of samples on the main surface. */ - s.AuxiliarySurfaceQPitch = - isl_surf_get_array_pitch_sa_rows(info->aux_surf) >> 2; + uint32_t aux_qpitch = isl_surf_get_array_pitch_sa_rows(info->aux_surf); + + /* From RENDER_SURFACE_STATE::AuxiliarySurfaceQPitch on BDW+, + * + * This field must be set to an integer multiple of the Surface + * Vertical Alignment + */ + assert(aux_qpitch % image_align.h == 0); + s.AuxiliarySurfaceQPitch = aux_qpitch >> 2; #endif } #endif