Mesa (main): panfrost: Add helpers to work with legacy strides

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 3 14:38:09 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed Apr 27 12:25:11 2022 -0400

panfrost: Add helpers to work with legacy strides

Unfortunately, the botched nonlinear "line strides" have become ingrained in the
UABI. We need to be work with them. Add safe helpers to convert to/from the
legacy strides.

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

---

 src/panfrost/lib/pan_layout.c  | 18 ++++++++++++++++++
 src/panfrost/lib/pan_texture.h |  9 +++++++++
 2 files changed, 27 insertions(+)

diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c
index 77842bec5e6..c53013c194d 100644
--- a/src/panfrost/lib/pan_layout.c
+++ b/src/panfrost/lib/pan_layout.c
@@ -164,6 +164,24 @@ panfrost_get_layer_stride(const struct pan_image_layout *layout,
                 return layout->slices[level].surface_stride;
 }
 
+unsigned
+panfrost_get_legacy_stride(const struct pan_image_layout *layout,
+                           unsigned level)
+{
+        unsigned row_stride = layout->slices[level].row_stride;
+        unsigned bh = panfrost_block_size(layout->modifier, layout->format).height;
+
+        return row_stride / bh;
+}
+
+unsigned
+panfrost_from_legacy_stride(unsigned legacy_stride,
+                            enum pipe_format format,
+                            uint64_t modifier)
+{
+        return legacy_stride * panfrost_block_size(modifier, format).height;
+}
+
 /* Computes the offset into a texture at a particular level/face. Add to
  * the base address of a texture to get the address to that level/face */
 
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index a2febecce3d..e9497f2c111 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -229,6 +229,15 @@ bool
 pan_image_layout_init(struct pan_image_layout *layout,
                       const struct pan_image_explicit_layout *explicit_layout);
 
+unsigned
+panfrost_get_legacy_stride(const struct pan_image_layout *layout,
+                           unsigned level);
+
+unsigned
+panfrost_from_legacy_stride(unsigned legacy_stride,
+                            enum pipe_format format,
+                            uint64_t modifier);
+
 struct pan_surface {
         union {
                 mali_ptr data;



More information about the mesa-commit mailing list