panfrost: Add panfrost_block_dim helper

So we can calculate strides of block-based formats correctly. Will help
us down the road for Bifrost AFBC.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index c65c60b..1600d0e 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -207,6 +207,28 @@
  */
 
 static unsigned
+panfrost_block_dim(uint64_t modifier, bool width, unsigned plane)
+{
+        if (!drm_is_afbc(modifier)) {
+                assert(modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED);
+                return 16;
+        }
+
+        switch (modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) {
+        case AFBC_FORMAT_MOD_BLOCK_SIZE_16x16:
+                return 16;
+        case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8:
+                return width ? 32 : 32;
+        case AFBC_FORMAT_MOD_BLOCK_SIZE_64x4:
+                return width ? 64 : 4;
+        case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4:
+                return plane ? (width ? 64 : 4) : (width ? 32 : 8);
+        default:
+                unreachable("Invalid AFBC block size");
+        }
+}
+
+static unsigned
 panfrost_nonlinear_stride(uint64_t modifier,
                 unsigned bytes_per_pixel,
                 unsigned width,