freedreno/a6xx+: Add support for the R8G8_R8B8 and G8R8_B8R8 formats.
authorEmma Anholt <emma@anholt.net>
Thu, 30 Sep 2021 18:03:49 +0000 (11:03 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 5 Oct 2021 20:09:17 +0000 (20:09 +0000)
This means that EGLimage imports of YUYV and UYVY can use a single sampler
instead of having to create RGBA8 and RG8 samplers mapping the same
texture.  The swizzles are the same as turnip uses, and it makes the
piglit tests for these formats happy.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13046>

src/freedreno/fdl/fd6_format_table.c
src/gallium/drivers/freedreno/a6xx/fd6_format.c

index b4a2740..8ff7cba 100644 (file)
@@ -345,6 +345,9 @@ static struct fd6_format formats[PIPE_FORMAT_COUNT] = {
    _T_(ASTC_12x10_SRGB, ASTC_12x10,             WZYX),
    _T_(ASTC_12x12_SRGB, ASTC_12x12,             WZYX),
 
+   _T_(R8G8_R8B8_UNORM, R8G8R8B8_422_UNORM, WZYX), /* YUYV */
+   _T_(G8R8_B8R8_UNORM, G8R8B8R8_422_UNORM, WZYX), /* UYVY */
+
    _T_(R8_G8B8_420_UNORM, R8_G8B8_2PLANE_420_UNORM, WZYX),
 };
 /* clang-format on */
index 42a7189..1d08f83 100644 (file)
@@ -65,6 +65,9 @@ fd6_tex_swiz(enum pipe_format format, unsigned char *swiz, unsigned swizzle_r,
       const unsigned char stencil_swiz[4] = {PIPE_SWIZZLE_W, PIPE_SWIZZLE_W,
                                              PIPE_SWIZZLE_W, PIPE_SWIZZLE_W};
       util_format_compose_swizzles(stencil_swiz, uswiz, swiz);
+   } else if (format == PIPE_FORMAT_R8G8_R8B8_UNORM || format == PIPE_FORMAT_G8R8_B8R8_UNORM) {
+      unsigned char fswiz[4] = {PIPE_SWIZZLE_Z, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_1};
+      util_format_compose_swizzles(fswiz, uswiz, swiz);
    } else if (fd6_pipe2swap(format) != WZYX) {
       /* Formats with a non-pass-through swap are permutations of RGBA
        * formats. We program the permutation using the swap and don't