From 81ebd6ea8d503b11e734077ecfc96d3470b7a0bc Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Fri, 23 Aug 2024 08:25:38 +0000 Subject: [PATCH] util/format: Add new 12-bit P012 RGB/planar formats Introduce three 12-bit formats: X4R12_UNORM, X4R12X4G12_UNORM, and X4G12_X4B12X4R12_420_UNORM. These formats allocate 12 bits for each color channel with 4 bits of padding to align with Vulkan's P012 and related planar formats. Reviewed-by: Faith Ekstrand Signed-off-by: Valentine Burley Part-of: --- src/util/format/u_format.yaml | 23 ++++++++++++++++++++++- src/util/format/u_format_table.py | 1 + src/util/format/u_formats.h | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/util/format/u_format.yaml b/src/util/format/u_format.yaml index 3924f7386d7..0eb73085ce1 100644 --- a/src/util/format/u_format.yaml +++ b/src/util/format/u_format.yaml @@ -1902,7 +1902,7 @@ swizzles: [X, 0, 0, 1] -# RGB versions of NV12, YV12, and P010 for hardware that supports sampling +# RGB versions of NV12, YV12, P010, and P012 for hardware that supports sampling # from multiplane textures but needs color-space conversion in the shader. - name: R8_G8B8_420_UNORM layout: planar2 @@ -1952,6 +1952,12 @@ block: {width: 1, height: 1, depth: 1} channels: [X6, UN10] swizzles: [X, Y, Z, W] +- name: X4G12_X4B12X4R12_420_UNORM + layout: planar2 + colorspace: RGB + block: {width: 1, height: 1, depth: 1} + channels: [X4, UN12] + swizzles: [X, Y, Z, W] # While most of Mesa uses R8 for Y, U, and V planes, freedreno requires # distinguishing between tiled Y8 data and tiled R8 data. @@ -1976,6 +1982,21 @@ channels: [X6, UN10, X6, UN10] swizzles: [Y, W, 0, 1] +# Formats for plane 0/plane 1 of P012 +- name: X4R12_UNORM + layout: plain + colorspace: RGB + block: {width: 1, height: 1, depth: 1} + channels: [X4, UN12] + swizzles: [Y, 0, 0, 1] +- name: X4R12X4G12_UNORM + layout: plain + colorspace: RGB + block: {width: 1, height: 1, depth: 1} + channels: [X4, UN12, X4, UN12] + swizzles: [Y, W, 0, 1] + + - name: Y8_U8_V8_422_UNORM layout: planar3 colorspace: YUV diff --git a/src/util/format/u_format_table.py b/src/util/format/u_format_table.py index 2fd2c93be84..bc91302e996 100644 --- a/src/util/format/u_format_table.py +++ b/src/util/format/u_format_table.py @@ -106,6 +106,7 @@ def has_access(format): 'g8b8_g8r8_unorm', 'b8g8_r8g8_unorm', 'x6g10_x6b10x6r10_420_unorm', + 'x4g12_x4b12x4r12_420_unorm', 'y8_400_unorm', 'y8_u8_v8_422_unorm', 'y8_u8v8_422_unorm', diff --git a/src/util/format/u_formats.h b/src/util/format/u_formats.h index 26ea4bed426..18c5cf3f014 100644 --- a/src/util/format/u_formats.h +++ b/src/util/format/u_formats.h @@ -238,10 +238,14 @@ enum pipe_format { PIPE_FORMAT_R8G8_B8G8_UNORM, PIPE_FORMAT_G8R8_G8B8_UNORM, PIPE_FORMAT_X6G10_X6B10X6R10_420_UNORM, + PIPE_FORMAT_X4G12_X4B12X4R12_420_UNORM, PIPE_FORMAT_X6R10_UNORM, PIPE_FORMAT_X6R10X6G10_UNORM, + PIPE_FORMAT_X4R12_UNORM, + PIPE_FORMAT_X4R12X4G12_UNORM, + /* mixed formats */ PIPE_FORMAT_R8SG8SB8UX8U_NORM, PIPE_FORMAT_R5SG5SB6U_NORM,