panfrost: Align WSI strides for tiled AFBC
authorAlyssa Rosenzweig <alyssa@collabora.com>
Wed, 14 Dec 2022 01:31:38 +0000 (20:31 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Dec 2022 18:27:47 +0000 (18:27 +0000)
When calculating legacy WSI strides for tiled AFBC, we need to account for the
greater alignment requirement of tiled AFBC, or importing resources will fail
later.

Since tiled AFBC is only supported on v7 and later, and AFBC of window surfaces
isn't being used on Linux on v7 and later, this probably hasn't been hit in
practice. Probably.

We're about to fix AFBC of window surfaces so we need to fix this side first.

Fixes: 0255f554f39 ("panfrost: Advertise 16x16 tiled AFBC")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20311>

src/panfrost/lib/pan_layout.c

index b64a2d7..aeaa10e 100644 (file)
@@ -237,8 +237,10 @@ panfrost_get_legacy_stride(const struct pan_image_layout *layout,
 
         if (drm_is_afbc(layout->modifier)) {
                 unsigned width = u_minify(layout->width, level);
-                width = ALIGN_POT(width, block_size.width);
+                unsigned alignment = block_size.width *
+                                     pan_afbc_tile_size(layout->modifier);
 
+                width = ALIGN_POT(width, alignment);
                 return width * util_format_get_blocksize(layout->format);
         } else {
                 return row_stride / block_size.height;