From cff496eee97f82134403e622557644e349fc5bc0 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 20 May 2025 18:46:19 +0200 Subject: [PATCH] pan/layout: Don't base the WSI row_pitch calculation on the image width If we want to allow the import path to specify padding tiles, we need to adjust pan_image_layout_get_wsi_layout() to base its WSI row pitch calculation on the AFBC header row stride instead of the image width. Signed-off-by: Boris Brezillon Tested-by: Eric R. Smith Reviewed-by: Eric R. Smith Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/lib/pan_layout.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index 1592c5f7454..f6f572b8dde 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -160,14 +160,18 @@ pan_image_layout_get_wsi_layout(const struct pan_image_props *props, pan_image_renderblock_size_el(props->modifier, props->format); if (drm_is_afbc(props->modifier)) { - unsigned width_px = u_minify(props->extent_px.width, level); - unsigned alignment_B = - block_size_el.width * pan_afbc_tile_size(props->modifier); - - width_px = ALIGN_POT(width_px, alignment_B); + struct pan_image_block_size afbc_tile_extent_px = + pan_afbc_superblock_size(props->modifier); + unsigned afbc_tile_payload_size_B = + afbc_tile_extent_px.width * afbc_tile_extent_px.height * + util_format_get_blocksize(props->format); + unsigned afbc_tile_row_payload_size_B = + pan_afbc_stride_blocks(props->modifier, row_stride_B) * + afbc_tile_payload_size_B; return (struct pan_image_wsi_layout){ .offset_B = layout->slices[level].offset_B, - .row_pitch_B = width_px * util_format_get_blocksize(props->format), + .row_pitch_B = afbc_tile_row_payload_size_B / + afbc_tile_extent_px.height, }; } else if (drm_is_afrc(props->modifier)) { struct pan_image_block_size tile_size_px =