Module: Mesa
Branch: staging/23.3
Commit: ae6c9315a8803c62f59e6e1f1ec1a11ef6beabdc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae6c9315a8803c62f59e6e1f1ec1a11ef6beabdc

Author: Boris Brezillon <[email protected]>
Date:   Wed Nov 29 18:53:54 2023 +0100

panfrost: Fix multiplanar YUV texture descriptor emission on v9+

Multiplanar YUV textures require two surface descriptors, and the
base address calculation should be moved inside the for loop,
otherwise we always take the base address of the first plane.

Fixes: 144f9324a374 ("panfrost: prepare v9+ to support YUV sampling")
Cc: stable
Signed-off-by: Boris Brezillon <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26425>
(cherry picked from commit 93e9bfcfd512858ccace258f1436bd0485a53b84)

---

 .pick_status.json              |  2 +-
 src/panfrost/lib/pan_texture.c | 23 +++++++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 37bd4428ff1..9452d8c40f2 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -514,7 +514,7 @@
         "description": "panfrost: Fix multiplanar YUV texture descriptor 
emission on v9+",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "144f9324a3747748191513c0a1a596171f193a82",
         "notes": null
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index 31240832deb..66e6a4f5e7c 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -540,15 +540,8 @@ panfrost_emit_surface(const struct pan_image_view *iview, 
unsigned level,
                       unsigned layer, unsigned face, unsigned sample,
                       enum pipe_format format, void **payload)
 {
-   const struct pan_image *base_image = pan_image_view_get_plane(iview, 0);
    ASSERTED const struct util_format_description *desc =
       util_format_description(format);
-   mali_ptr base = base_image->data.bo->ptr.gpu + base_image->data.offset;
-
-   if (iview->buf.size) {
-      assert(iview->dim == MALI_TEXTURE_DIMENSION_1D);
-      base += iview->buf.offset;
-   }
 
    const struct pan_image_layout *layouts[MAX_IMAGE_PLANES] = {0};
    mali_ptr plane_ptrs[MAX_IMAGE_PLANES] = {0};
@@ -556,12 +549,21 @@ panfrost_emit_surface(const struct pan_image_view *iview, 
unsigned level,
    int32_t surface_strides[MAX_IMAGE_PLANES] = {0};
 
    for (int i = 0; i < MAX_IMAGE_PLANES; i++) {
-      if (!pan_image_view_get_plane(iview, i)) {
+      const struct pan_image *base_image = pan_image_view_get_plane(iview, i);
+
+      if (!base_image) {
          /* Every texture should have at least one plane. */
          assert(i > 0);
          break;
       }
 
+      mali_ptr base = base_image->data.bo->ptr.gpu + base_image->data.offset;
+
+      if (iview->buf.size) {
+         assert(iview->dim == MALI_TEXTURE_DIMENSION_1D);
+         base += iview->buf.offset;
+      }
+
       layouts[i] = &pan_image_view_get_plane(iview, i)->layout;
 
       /* v4 does not support compression */
@@ -742,6 +744,11 @@ GENX(panfrost_new_texture)(const struct panfrost_device 
*dev,
       array_size /= 6;
    }
 
+   /* Multiplanar YUV textures require 2 surface descriptors. */
+   if (panfrost_is_yuv(desc->layout) && PAN_ARCH >= 9 &&
+       pan_image_view_get_plane(iview, 1) != NULL)
+      array_size *= 2;
+
    unsigned width;
 
    if (iview->buf.size) {

Reply via email to