Mesa (main): panfrost: Assert alignment in tiling routine

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 16 14:13:59 UTC 2022


Module: Mesa
Branch: main
Commit: 1d8ea7764562c808cac90802818e1e94ec9085f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d8ea7764562c808cac90802818e1e94ec9085f8

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Thu Apr 14 10:34:51 2022 -0400

panfrost: Assert alignment in tiling routine

We depend on this invariant implicitly. Make that dependence explicit so we
don't get confused and add broken unit tests.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15803>

---

 src/panfrost/shared/pan_tiling.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/panfrost/shared/pan_tiling.c b/src/panfrost/shared/pan_tiling.c
index 5ef40516608..d19c5ab5307 100644
--- a/src/panfrost/shared/pan_tiling.c
+++ b/src/panfrost/shared/pan_tiling.c
@@ -313,6 +313,15 @@ panfrost_access_tiled_image(void *dst, void *src,
                            bool is_store)
 {
    const struct util_format_description *desc = util_format_description(format);
+   unsigned bpp = desc->block.bits;
+
+   /* Our optimized routines cannot handle unaligned blocks (without depending
+    * on platform-specific behaviour), and there is no good reason to do so. If
+    * these assertions fail, there is either a driver bug or a non-portable unit
+    * test.
+    */
+   assert((dst_stride % (bpp / 8)) == 0 && "unaligned destination stride");
+   assert((src_stride % (bpp / 8)) == 0 && "unaligned source stride");
 
    if (desc->block.width > 1 || !util_is_power_of_two_nonzero(desc->block.bits)) {
       panfrost_access_tiled_image_generic(dst, (void *) src,
@@ -322,7 +331,6 @@ panfrost_access_tiled_image(void *dst, void *src,
       return;
    }
 
-   unsigned bpp = desc->block.bits;
    unsigned first_full_tile_x = DIV_ROUND_UP(x, TILE_WIDTH) * TILE_WIDTH;
    unsigned first_full_tile_y = DIV_ROUND_UP(y, TILE_HEIGHT) * TILE_HEIGHT;
    unsigned last_full_tile_x = ((x + w) / TILE_WIDTH) * TILE_WIDTH;



More information about the mesa-commit mailing list