util/format: Add G8B8_G8R8_422_UNORM and B8G8_R8G8_422_UNORM formats
authorMohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Thu, 10 Aug 2023 16:37:01 +0000 (19:37 +0300)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Aug 2023 23:44:19 +0000 (23:44 +0000)
These actually match the Vulkan format enums for single-plane YCbCr
formats, unlike the other PIPE_FORMAT_* enums which put luminance in the
red channel.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24619>

src/util/format/u_format.csv
src/util/format/u_format_table.py
src/util/format/u_format_tests.c
src/util/format/u_formats.h

index c47ec0c..9c648f2 100644 (file)
@@ -192,6 +192,8 @@ PIPE_FORMAT_G8R8_B8R8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8
 PIPE_FORMAT_R8G8_R8B8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb
 PIPE_FORMAT_B8R8_G8R8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8 , yxz1, rgb
 PIPE_FORMAT_R8B8_R8G8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8 , yxz1, rgb
+PIPE_FORMAT_G8B8_G8R8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8 , xyz1, rgb
+PIPE_FORMAT_B8G8_R8G8_UNORM         , subsampled, 2, 1, 1, un8 , un8 , un8 , un8 , xyz1, rgb
 
 # some special formats not fitting anywhere else
 PIPE_FORMAT_R11G11B10_FLOAT         , other,     1, 1, 1, f11 , f11 , f10 ,     , xyz1, rgb
index 26b58ee..35f2872 100644 (file)
@@ -104,6 +104,8 @@ def has_access(format):
         'g8r8_b8r8_unorm',
         'b8r8_g8r8_unorm',
         'g8r8_g8b8_unorm',
+        'g8b8_g8r8_unorm',
+        'b8g8_r8g8_unorm',
         'y8_400_unorm',
         'y8_u8_v8_422_unorm',
         'y8_u8v8_422_unorm',
index e7ae865..652567d 100644 (file)
@@ -432,6 +432,20 @@ util_format_test_cases[] =
    {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)},
    {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
 
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)},
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)},
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_G8B8_G8R8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
+
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)},
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)},
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)},
+   {PIPE_FORMAT_B8G8_R8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
+
    /*
     * TODO: Exercise the UV channels as well.
     */
index 22fb414..a48b124 100644 (file)
@@ -368,6 +368,8 @@ enum pipe_format {
    PIPE_FORMAT_R8B8_R8G8_UNORM,
    PIPE_FORMAT_G8R8_B8R8_UNORM,
    PIPE_FORMAT_B8R8_G8R8_UNORM,
+   PIPE_FORMAT_G8B8_G8R8_UNORM,
+   PIPE_FORMAT_B8G8_R8G8_UNORM,
 
    PIPE_FORMAT_R8G8B8X8_SNORM,
    PIPE_FORMAT_R8G8B8X8_SRGB,