panfrost: Implement YTR availability check

Depends on format.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Icecream95 <ixn@keemail.me>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6159>
diff --git a/src/panfrost/lib/pan_afbc.c b/src/panfrost/lib/pan_afbc.c
index f1f62ba..a75e797 100644
--- a/src/panfrost/lib/pan_afbc.c
+++ b/src/panfrost/lib/pan_afbc.c
@@ -128,3 +128,19 @@
         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 a085e5a..fa3918f 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -85,6 +85,9 @@
 unsigned
 panfrost_afbc_header_size(unsigned width, unsigned height);
 
+bool
+panfrost_afbc_can_ytr(enum pipe_format format);
+
 /* mali_texture_descriptor */
 
 unsigned