panfrost: Implement YTR availability check
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 22 Jul 2020 15:07:03 +0000 (11:07 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Aug 2020 13:59:20 +0000 (09:59 -0400)
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>

src/panfrost/lib/pan_afbc.c
src/panfrost/lib/pan_texture.h

index f1f62baffc9495cbf06d88b328337306dadacb24..a75e797190c24594b4f058dcd2b5da9b80971ac7 100644 (file)
@@ -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;
+}
index a085e5a7fe788a72a4345a696ddccb53fa7cff2a..fa3918f0f2ee9c2a89c24586bbfdd9d6aa984fca 100644 (file)
@@ -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