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

Author: Alyssa Rosenzweig <[email protected]>
Date:   Tue Nov  8 11:54:11 2022 -0500

ail: Add get_wsi_stride_B helper

Centralize the logic around WSI strides, which are a software convention made
into UAPI rather than something set in silicon.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19606>

---

 src/asahi/layout/layout.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h
index 9171e3f0de4..91a5cf5ea5a 100644
--- a/src/asahi/layout/layout.h
+++ b/src/asahi/layout/layout.h
@@ -116,6 +116,25 @@ ail_get_linear_stride_B(struct ail_layout *layout, 
ASSERTED uint8_t level)
    return layout->linear_stride_B;
 }
 
+/*
+ * For WSI purposes, we need to associate a stride with all layouts. In the
+ * hardware, only strided linear images have an associated stride, there is no
+ * natural stride associated with twiddled images. However, various clients
+ * assert that the stride is valid for the image if it were linear (even if it
+ * is in fact not linear). In those cases, by convention we use the minimum
+ * valid such stride.
+ */
+static inline uint32_t
+ail_get_wsi_stride_B(struct ail_layout *layout, unsigned level)
+{
+   assert(level == 0 && "Mipmaps cannot be shared as WSI");
+
+   if (layout->tiling == AIL_TILING_LINEAR)
+      return ail_get_linear_stride_B(layout, level);
+   else
+      return util_format_get_stride(layout->format, layout->width_px);
+}
+
 static inline uint32_t
 ail_get_layer_offset_B(struct ail_layout *layout, unsigned z_px)
 {

Reply via email to