Mesa (main): panfrost: Extract panfrost_afbc_is_wide helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 26 18:19:26 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Sat Apr 16 10:31:18 2022 -0400

panfrost: Extract panfrost_afbc_is_wide helper

Rather than open-code the > 16 check in multiple places and have to justify it
in each. This is easier to understand at the call sites.

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

---

 src/panfrost/lib/pan_cs.c      |  2 +-
 src/panfrost/lib/pan_layout.c  | 11 +++++++++++
 src/panfrost/lib/pan_texture.c |  3 +--
 src/panfrost/lib/pan_texture.h |  2 ++
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/panfrost/lib/pan_cs.c b/src/panfrost/lib/pan_cs.c
index d0f67c495e5..e0f451c3f9e 100644
--- a/src/panfrost/lib/pan_cs.c
+++ b/src/panfrost/lib/pan_cs.c
@@ -451,7 +451,7 @@ pan_prepare_rt(const struct pan_fb_info *fb, unsigned idx,
                 cfg->afbc.row_stride = slice->afbc.row_stride /
                                        AFBC_HEADER_BYTES_PER_TILE;
                 cfg->afbc.afbc_wide_block_enable =
-                        panfrost_afbc_superblock_width(rt->image->layout.modifier) > 16;
+                        panfrost_afbc_is_wide(rt->image->layout.modifier);
 #else
                 cfg->afbc.chunk_size = 9;
                 cfg->afbc.sparse = true;
diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c
index a5ccdf7692b..685783c1e57 100644
--- a/src/panfrost/lib/pan_layout.c
+++ b/src/panfrost/lib/pan_layout.c
@@ -89,6 +89,17 @@ panfrost_afbc_superblock_height(uint64_t modifier)
         return panfrost_afbc_superblock_size(modifier).height;
 }
 
+/*
+ * Given an AFBC modifier, return if "wide blocks" are used. Wide blocks are
+ * defined as superblocks wider than 16 pixels, the minimum (and default) super
+ * block width.
+ */
+unsigned
+panfrost_afbc_is_wide(uint64_t modifier)
+{
+        return panfrost_afbc_superblock_width(modifier) > 16;
+}
+
 /* If not explicitly, line stride is calculated for block-based formats as
  * (ceil(width / block_width) * block_size). As a special case, this is left
  * zero if there is only a single block vertically. So, we have a helper to
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index 0ef88f11d59..9001389d5db 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -81,8 +81,7 @@ panfrost_compression_tag(const struct util_format_description *desc,
                 /* Prefetch enable */
                 flags |= MALI_AFBC_SURFACE_FLAG_PREFETCH;
 
-                /* Wide blocks (> 16x16) */
-                if (panfrost_afbc_superblock_width(modifier) > 16)
+                if (panfrost_afbc_is_wide(modifier))
                         flags |= MALI_AFBC_SURFACE_FLAG_WIDE_BLOCK;
 
                 /* Used to make sure AFBC headers don't point outside the AFBC
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index 607b8a2724b..1e030319ae9 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -177,6 +177,8 @@ unsigned panfrost_afbc_superblock_width(uint64_t modifier);
 
 unsigned panfrost_afbc_superblock_height(uint64_t modifier);
 
+unsigned panfrost_afbc_is_wide(uint64_t modifier);
+
 #ifdef PAN_ARCH
 unsigned
 GENX(panfrost_estimate_texture_payload_size)(const struct pan_image_view *iview);



More information about the mesa-commit mailing list