Mesa (master): panfrost: Fix tiled texture "stride"s on Bifrost

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 1 00:49:38 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Thu Apr 30 18:48:53 2020 -0400

panfrost: Fix tiled texture "stride"s on Bifrost

They're not real strides like linear textures but the hw does use them
so we do have to get it right annoyingly.

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

---

 src/panfrost/encoder/pan_texture.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/panfrost/encoder/pan_texture.c b/src/panfrost/encoder/pan_texture.c
index fe13a03eec4..3f5d26680a7 100644
--- a/src/panfrost/encoder/pan_texture.c
+++ b/src/panfrost/encoder/pan_texture.c
@@ -166,6 +166,24 @@ panfrost_estimate_texture_payload_size(
         return sizeof(mali_ptr) * elements;
 }
 
+/* Bifrost requires a tile stride for tiled textures. This stride is computed
+ * as (16 * bpp * width) assuming there is at least one tile (width >= 16).
+ * Otherwise if width < 16, the blob puts zero. Interactions with AFBC are
+ * currently unknown.
+ */
+
+static unsigned
+panfrost_nonlinear_stride(enum mali_texture_layout layout,
+                unsigned bytes_per_pixel,
+                unsigned width)
+{
+        if (layout == MALI_TEXTURE_TILED) {
+                return (width < 16) ? 0 : (16 * bytes_per_pixel * width);
+        } else {
+                unreachable("TODO: AFBC on Bifrost");
+        }
+}
+
 static void
 panfrost_emit_texture_payload(
         mali_ptr *payload,
@@ -173,6 +191,7 @@ panfrost_emit_texture_payload(
         enum mali_format mali_format,
         enum mali_texture_type type,
         enum mali_texture_layout layout,
+        unsigned width,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
         unsigned cube_stride,
@@ -201,8 +220,13 @@ panfrost_emit_texture_payload(
                                                 slices, type == MALI_TEX_3D,
                                                 cube_stride, l, w * face_mult + f);
 
-                                if (manual_stride)
-                                        payload[idx++] = slices[l].stride;
+                                if (manual_stride) {
+                                        payload[idx++] = (layout == MALI_TEXTURE_LINEAR) ?
+                                                slices[l].stride :
+                                                panfrost_nonlinear_stride(layout,
+                                                                MAX2(desc->block.bits / 8, 1),
+                                                                u_minify(width, l));
+                                }
                         }
                 }
         }
@@ -261,6 +285,7 @@ panfrost_new_texture(
                 mali_format,
                 type,
                 layout,
+                width,
                 first_level, last_level,
                 first_layer, last_layer,
                 cube_stride,
@@ -290,19 +315,17 @@ panfrost_new_texture_bifrost(
 
         enum mali_format mali_format = panfrost_find_format(desc);
 
-        /* Apparently it's always needed in Bifrost? */
-        bool manual_stride = true;
-
         panfrost_emit_texture_payload(
                 (mali_ptr *) payload->cpu,
                 desc,
                 mali_format,
                 type,
                 layout,
+                width,
                 first_level, last_level,
                 first_layer, last_layer,
                 cube_stride,
-                manual_stride,
+                true, /* Stride explicit on Bifrost */
                 base,
                 slices);
 



More information about the mesa-commit mailing list