Mesa (main): panfrost: Support tiled AFBC in stride helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 26 16:12:43 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed May  4 10:01:32 2022 -0400

panfrost: Support tiled AFBC in stride helpers

Part 1 of tiled AFBC. This requires modifier information.

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

---

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

diff --git a/src/panfrost/lib/pan_cs.c b/src/panfrost/lib/pan_cs.c
index d010dd29f01..e3f2be599b8 100644
--- a/src/panfrost/lib/pan_cs.c
+++ b/src/panfrost/lib/pan_cs.c
@@ -206,7 +206,7 @@ pan_prepare_zs(const struct pan_fb_info *fb,
 #if PAN_ARCH >= 6
                 const struct pan_image_slice_layout *slice = &zs->image->layout.slices[level];
 
-                ext->zs_afbc_row_stride = pan_afbc_stride_blocks(slice->row_stride);
+                ext->zs_afbc_row_stride = pan_afbc_stride_blocks(zs->image->layout.modifier, slice->row_stride);
 #else
                 ext->zs_block_format = MALI_BLOCK_FORMAT_AFBC;
                 ext->zs_afbc_body_size = 0x1000;
@@ -447,7 +447,7 @@ pan_prepare_rt(const struct pan_fb_info *fb, unsigned idx,
                 const struct pan_image_slice_layout *slice = &rt->image->layout.slices[level];
 
 #if PAN_ARCH >= 6
-                cfg->afbc.row_stride = pan_afbc_stride_blocks(slice->row_stride);
+                cfg->afbc.row_stride = pan_afbc_stride_blocks(rt->image->layout.modifier, slice->row_stride);
                 cfg->afbc.afbc_wide_block_enable =
                         panfrost_afbc_is_wide(rt->image->layout.modifier);
 #else
diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c
index b16a00d420f..db0cfa8d996 100644
--- a/src/panfrost/lib/pan_layout.c
+++ b/src/panfrost/lib/pan_layout.c
@@ -143,25 +143,30 @@ pan_afbc_tile_size(uint64_t modifier)
 /*
  * Determine the number of bytes between header rows for an AFBC image. For an
  * image with linear headers, this is simply the number of header blocks
- * (=superblocks) per row  times the numbers of bytes per header block.
+ * (=superblocks) per row times the numbers of bytes per header block. For an
+ * image with linear headers, this is multipled by the number of rows of
+ * header blocks are in a tile together.
  */
 uint32_t
 pan_afbc_row_stride(uint64_t modifier, uint32_t width)
 {
         unsigned block_width = panfrost_afbc_superblock_width(modifier);
 
-        return (width / block_width) * AFBC_HEADER_BYTES_PER_TILE;
+        return (width / block_width) * pan_afbc_tile_size(modifier) *
+                AFBC_HEADER_BYTES_PER_TILE;
 }
 
 /*
  * Determine the number of header blocks between header rows. This is equal to
  * the number of bytes between header rows divided by the bytes per blocks of a
- * header tile
+ * header tile. This is also divided by the tile size to give a "line stride" in
+ * blocks, rather than a real row stride. This is required by Bifrost.
  */
 uint32_t
-pan_afbc_stride_blocks(uint32_t row_stride_bytes)
+pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes)
 {
-        return row_stride_bytes / AFBC_HEADER_BYTES_PER_TILE;
+        return row_stride_bytes /
+               (AFBC_HEADER_BYTES_PER_TILE * pan_afbc_tile_size(modifier));
 }
 
 /* Computes sizes for checksumming, which is 8 bytes per 16x16 tile.
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index 4cf9e6cd36c..a183bd8ce6c 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -196,7 +196,7 @@ bool panfrost_afbc_is_wide(uint64_t modifier);
 
 uint32_t pan_afbc_row_stride(uint64_t modifier, uint32_t width);
 
-uint32_t pan_afbc_stride_blocks(uint32_t row_stride_bytes);
+uint32_t pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes);
 
 struct pan_block_size
 panfrost_block_size(uint64_t modifier, enum pipe_format format);



More information about the mesa-commit mailing list