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

Author: Italo Nicola <[email protected]>
Date:   Wed Jun 28 22:25:26 2023 +0000

panfrost: add PAN_MESA_DEBUG=yuv for debugging yuv sampler

Signed-off-by: Italo Nicola <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21109>

---

 src/gallium/drivers/panfrost/pan_screen.c |  1 +
 src/panfrost/lib/pan_texture.c            | 10 ++++++++++
 src/panfrost/lib/pan_util.h               |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/src/gallium/drivers/panfrost/pan_screen.c 
b/src/gallium/drivers/panfrost/pan_screen.c
index 18e5737caf9..0286c01e7bb 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -71,6 +71,7 @@ static const struct debug_named_value 
panfrost_debug_options[] = {
 #ifdef PAN_DBG_OVERFLOW
    {"overflow",   PAN_DBG_OVERFLOW, "Check for buffer overflows in pool 
uploads"},
 #endif
+   {"yuv",        PAN_DBG_YUV,      "Tint YUV textures with blue for 1-plane 
and green for 2-plane"},
    DEBUG_NAMED_VALUE_END
 };
 /* clang-format on */
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index 49d4c0f7473..19d9f97cd95 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -670,6 +670,16 @@ GENX(panfrost_new_texture)(const struct panfrost_device 
*dev,
       memcpy(swizzle, iview->swizzle, sizeof(swizzle));
    }
 
+   if ((dev->debug & PAN_DBG_YUV) && PAN_ARCH == 7 &&
+       panfrost_needs_multiplanar_descriptor(desc->layout)) {
+      if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
+         swizzle[2] = PIPE_SWIZZLE_1;
+      } else if (desc->layout == UTIL_FORMAT_LAYOUT_PLANAR2) {
+         swizzle[1] = PIPE_SWIZZLE_0;
+         swizzle[2] = PIPE_SWIZZLE_0;
+      }
+   }
+
    panfrost_emit_texture_payload(iview, format, payload->cpu);
 
    unsigned array_size = iview->last_layer - iview->first_layer + 1;
diff --git a/src/panfrost/lib/pan_util.h b/src/panfrost/lib/pan_util.h
index d73f17ab666..03ada217c30 100644
--- a/src/panfrost/lib/pan_util.h
+++ b/src/panfrost/lib/pan_util.h
@@ -52,6 +52,8 @@
 #define PAN_DBG_OVERFLOW 0x8000
 #endif
 
+#define PAN_DBG_YUV 0x20000
+
 struct panfrost_device;
 
 unsigned panfrost_translate_swizzle_4(const unsigned char swizzle[4]);

Reply via email to