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

Author: Louis-Francis Ratté-Boulianne <[email protected]>
Date:   Thu Aug 31 11:19:45 2023 -0400

panfrost: Add methods to determine slice and body alignment

Those methods are needed to have the same alignment everywhere
without hard-coding the values

Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>

---

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

diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c
index 472568b1c63..04751c9572e 100644
--- a/src/panfrost/lib/pan_layout.c
+++ b/src/panfrost/lib/pan_layout.c
@@ -173,12 +173,21 @@ 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 slice offset of an image. For
+ * now, this is always aligned on 64-byte boundaries. */
+uint32_t
+pan_slice_align(uint64_t modifier)
+{
+   return 64;
+}
+
 /*
  * 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
+uint32_t
 pan_afbc_body_align(uint64_t modifier)
 {
    return (modifier & AFBC_FORMAT_MOD_TILED) ? 4096 : 64;
@@ -359,7 +368,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
       /* Align levels to cache-line as a performance improvement for
        * linear/tiled and as a requirement for AFBC */
 
-      offset = ALIGN_POT(offset, 64);
+      offset = ALIGN_POT(offset, pan_slice_align(layout->modifier));
 
       slice->offset = offset;
 
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index 790e34dd1ef..001818320a9 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -253,6 +253,10 @@ uint32_t pan_afbc_row_stride(uint64_t modifier, uint32_t 
width);
 
 uint32_t pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes);
 
+uint32_t pan_slice_align(uint64_t modifier);
+
+uint32_t pan_afbc_body_align(uint64_t modifier);
+
 struct pan_block_size panfrost_block_size(uint64_t modifier,
                                           enum pipe_format format);
 

Reply via email to