panfrost: Only use AFBC YTR with RGB and RGBA
authorIcecream95 <ixn@keemail.me>
Tue, 2 Jun 2020 02:14:12 +0000 (14:14 +1200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 15:19:43 +0000 (15:19 +0000)
The "lossless colorspace transform" is lossy for R and RG formats.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5293>

src/gallium/drivers/panfrost/pan_mfbd.c
src/panfrost/encoder/pan_texture.c

index 4b762d1b6466ea42953cb223cd9ccaa3d3a86803..62d86a678e74dbaebf4de364c9ad91b52a934247 100644 (file)
@@ -241,7 +241,13 @@ panfrost_mfbd_set_cbuf(
                 rt->framebuffer = base + header_size;
                 rt->afbc.metadata = base;
                 rt->afbc.stride = 0;
-                rt->afbc.flags = MALI_AFBC_FLAGS | MALI_AFBC_YTR;
+                rt->afbc.flags = MALI_AFBC_FLAGS;
+
+                unsigned components = util_format_get_nr_components(surf->format);
+
+                /* The "lossless colorspace transform" is lossy for R and RG formats */
+                if (components >= 3)
+                   rt->afbc.flags |= MALI_AFBC_YTR;
 
                 /* TODO: The blob sets this to something nonzero, but it's not
                  * clear what/how to calculate/if it matters */
index 22ff30828cadb04bbf98be9293c8e41d4d5f8769..cfd66c78c43c1aab64152e10e3f8be451f10f100 100644 (file)
@@ -82,8 +82,10 @@ panfrost_astc_stretch(unsigned dim)
         return MIN2(dim, 11) - 4;
 }
 
-/* Texture addresses are tagged with information about AFBC (colour AFBC?) xor
- * ASTC (stretch factor) if in use. */
+/* Texture addresses are tagged with information about compressed formats.
+ * AFBC uses a bit for whether the colorspace transform is enabled (RGB and
+ * RGBA only).
+ * For ASTC, this is a "stretch factor" encoding the block size. */
 
 static unsigned
 panfrost_compression_tag(
@@ -91,7 +93,7 @@ panfrost_compression_tag(
                 enum mali_format format, enum mali_texture_layout layout)
 {
         if (layout == MALI_TEXTURE_AFBC)
-                return util_format_has_depth(desc) ? 0x0 : 0x1;
+                return desc->nr_channels >= 3;
         else if (format == MALI_ASTC_HDR_SUPP || format == MALI_ASTC_SRGB_SUPP)
                 return (panfrost_astc_stretch(desc->block.height) << 3) |
                         panfrost_astc_stretch(desc->block.width);