Mesa (main): panfrost: Calculate header_size based on row_stride

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


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed May  4 11:16:11 2022 -0400

panfrost: Calculate header_size based on row_stride

The header size is the header stride times the number of rows in the header
(number of tiles of superblocks). We already calculate the header stride, so
eliminate the separate header size calculation.

Delete the old header size calculation. It has no notion of wide blocks, let
alone tiled AFBC headers.

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

---

 src/panfrost/lib/pan_afbc.c    | 24 ------------------------
 src/panfrost/lib/pan_layout.c  | 16 ++++++++++++++--
 src/panfrost/lib/pan_texture.h |  3 ---
 3 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/src/panfrost/lib/pan_afbc.c b/src/panfrost/lib/pan_afbc.c
index 08cc4b49dc3..bd8b3e710e6 100644
--- a/src/panfrost/lib/pan_afbc.c
+++ b/src/panfrost/lib/pan_afbc.c
@@ -66,10 +66,6 @@
  * generate a linear staging buffer and use the GPU to blit AFBC<--->linear.
  */
 
-#define AFBC_TILE_WIDTH 16
-#define AFBC_TILE_HEIGHT 16
-#define AFBC_CACHE_ALIGN 64
-
 /* AFBC supports compressing a few canonical formats. Additional formats are
  * available by using a canonical internal format. Given a PIPE format, find
  * the canonical AFBC internal format if it exists, or NONE if the format
@@ -135,26 +131,6 @@ panfrost_format_supports_afbc(const struct panfrost_device *dev, enum pipe_forma
         return panfrost_afbc_format(dev, format) != PIPE_FORMAT_NONE;
 }
 
-unsigned
-panfrost_afbc_header_size(unsigned width, unsigned height)
-{
-        /* Align to tile */
-        unsigned aligned_width  = ALIGN_POT(width,  AFBC_TILE_WIDTH);
-        unsigned aligned_height = ALIGN_POT(height, AFBC_TILE_HEIGHT);
-
-        /* Compute size in tiles, rather than pixels */
-        unsigned tile_count_x = aligned_width  / AFBC_TILE_WIDTH;
-        unsigned tile_count_y = aligned_height / AFBC_TILE_HEIGHT;
-        unsigned tile_count = tile_count_x * tile_count_y;
-
-        /* Multiply to find the header size */
-        unsigned header_bytes = tile_count * AFBC_HEADER_BYTES_PER_TILE;
-
-        /* Align and go */
-        return ALIGN_POT(header_bytes, AFBC_CACHE_ALIGN);
-
-}
-
 /* The lossless colour transform (AFBC_FORMAT_MOD_YTR) requires RGB. */
 
 bool
diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c
index d55d7b862aa..4d63642d585 100644
--- a/src/panfrost/lib/pan_layout.c
+++ b/src/panfrost/lib/pan_layout.c
@@ -169,6 +169,17 @@ pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes)
                (AFBC_HEADER_BYTES_PER_TILE * pan_afbc_tile_size(modifier));
 }
 
+/*
+ * Determine the required alignment for the body offset of an AFBC image. For
+ * now, this depends only on whether tiling is in use. These minimum alignments
+ * are required on all current GPUs.
+ */
+static inline uint32_t
+pan_afbc_body_align(uint64_t modifier)
+{
+        return (modifier & AFBC_FORMAT_MOD_TILED) ? 4096 : 64;
+}
+
 /* Computes sizes for checksumming, which is 8 bytes per 16x16 tile.
  * Checksumming is believed to be a CRC variant (CRC64 based on the size?).
  * This feature is also known as "transaction elimination". */
@@ -327,10 +338,11 @@ pan_image_layout_init(struct pan_image_layout *layout,
 
                 /* Compute AFBC sizes if necessary */
                 if (afbc) {
-                        slice->afbc.header_size =
-                                panfrost_afbc_header_size(width, height);
                         slice->row_stride =
                                 pan_afbc_row_stride(layout->modifier, effective_width);
+                        slice->afbc.header_size =
+                                ALIGN_POT(slice->row_stride * (effective_height / align_h),
+                                          pan_afbc_body_align(layout->modifier));
 
                         if (explicit_layout && explicit_layout->row_stride < slice->row_stride)
                                 return false;
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index a183bd8ce6c..9c9a3f21ee9 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -168,9 +168,6 @@ panfrost_afbc_format(const struct panfrost_device *dev, enum pipe_format format)
 
 #define AFBC_HEADER_BYTES_PER_TILE 16
 
-unsigned
-panfrost_afbc_header_size(unsigned width, unsigned height);
-
 bool
 panfrost_afbc_can_ytr(enum pipe_format format);
 



More information about the mesa-commit mailing list