Mesa (master): panfrost: Implement YTR availability check

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 12 14:16:32 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Wed Jul 22 11:07:03 2020 -0400

panfrost: Implement YTR availability check

Depends on format.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Tested-by: Icecream95 <ixn at keemail.me>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6159>

---

 src/panfrost/lib/pan_afbc.c    | 16 ++++++++++++++++
 src/panfrost/lib/pan_texture.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/src/panfrost/lib/pan_afbc.c b/src/panfrost/lib/pan_afbc.c
index f1f62baffc9..a75e797190c 100644
--- a/src/panfrost/lib/pan_afbc.c
+++ b/src/panfrost/lib/pan_afbc.c
@@ -128,3 +128,19 @@ panfrost_afbc_header_size(unsigned width, unsigned height)
         return ALIGN_POT(header_bytes, AFBC_CACHE_ALIGN);
 
 }
+
+/* The lossless colour transform (AFBC_FORMAT_MOD_YTR) requires RGB. */
+
+bool
+panfrost_afbc_can_ytr(enum pipe_format format)
+{
+        const struct util_format_description *desc =
+                util_format_description(format);
+
+        /* YTR is only defined for RGB(A) */
+        if (desc->nr_channels != 3 && desc->nr_channels != 4)
+                return false;
+
+        /* The fourth channel if it exists doesn't matter */
+        return desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB;
+}
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index a085e5a7fe7..fa3918f0f2e 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -85,6 +85,9 @@ panfrost_format_supports_afbc(enum pipe_format format);
 unsigned
 panfrost_afbc_header_size(unsigned width, unsigned height);
 
+bool
+panfrost_afbc_can_ytr(enum pipe_format format);
+
 /* mali_texture_descriptor */
 
 unsigned



More information about the mesa-commit mailing list