util/format: add support for YU08 and YU10 formats

Adds support for single plane YUV 420 formats (YU08 and YU10 fourcc
codes). The internal layout for these is unspecified and driver
specific.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35318>
This commit is contained in:
Eric R. Smith 2025-04-14 15:24:10 -03:00 committed by Boris Brezillon
parent bb22697437
commit d4f83a96c9
3 changed files with 43 additions and 0 deletions

View file

@ -2100,6 +2100,22 @@
channels: [X4, UN12]
swizzles: [X, Y, Z, W]
# for YUV420_8BIT, each 2x2 block needs 6 8 bit values to describe it
- name: R8G8B8_420_UNORM_PACKED
layout: subsampled
colorspace: RGB
block: {width: 2, height: 2, depth: 1}
channels: [X48]
swizzles: [X, Y, Z, 1]
# similarly for YUV420_10BIT, for a 2x2 block we need 60 bits; but this
# does not fit in an even multiple of bytes, so do a 4x2 block -> 120 bits
- name: R10G10B10_420_UNORM_PACKED
layout: subsampled
colorspace: RGB
block: {width: 4, height: 2, depth: 1}
channels: [X120]
swizzles: [X, Y, Z, 1]
# While most of Mesa uses R8 for Y, U, and V planes, freedreno requires
# distinguishing between tiled Y8 data and tiled R8 data.
- name: Y8_UNORM
@ -2255,6 +2271,20 @@
channels: [UN16, UN16, UN16, UN16]
swizzles: [Y, Z, X, W]
# YUV 420 with an unspecified (hardware specific) internal format
# (block: {width: 1, height: 1, depth: 1} is a lie)
- name: Y8U8V8_420_UNORM_PACKED
layout: subsampled
colorspace: YUV
block: {width: 1, height: 1, depth: 1}
channels: []
swizzles: [X, Y, Z, W]
- name: Y10U10V10_420_UNORM_PACKED
layout: subsampled
colorspace: YUV
block: {width: 1, height: 1, depth: 1}
channels: []
swizzles: [X, Y, Z, W]
# Usually used to implement IA44 and AI44 formats in video decoding
- name: A4R4_UNORM

View file

@ -129,7 +129,11 @@ def has_access(format):
'r8_b8_g8_420_unorm',
'g8_b8_r8_420_unorm',
'r8_g8_b8_unorm',
'r8g8b8_420_unorm_packed',
'r10g10b10_420_unorm_packed',
'y8_unorm',
'y8u8v8_420_unorm_packed',
'y10u10v10_420_unorm_packed',
]
if format.short_name() in noaccess_formats:
return False

View file

@ -323,6 +323,11 @@ enum pipe_format {
PIPE_FORMAT_Y16_U16V16_422_UNORM,
PIPE_FORMAT_Y16_U16_V16_444_UNORM,
/* These formats have a single plane in a hardware-specific internal
* layout. */
PIPE_FORMAT_Y8U8V8_420_UNORM_PACKED,
PIPE_FORMAT_Y10U10V10_420_UNORM_PACKED,
PIPE_FORMAT_A4R4_UNORM,
PIPE_FORMAT_R4A4_UNORM,
PIPE_FORMAT_R8A8_UNORM,
@ -540,9 +545,11 @@ enum pipe_format {
PIPE_FORMAT_AYUV,
PIPE_FORMAT_XYUV,
PIPE_FORMAT_R8G8B8_420_UNORM_PACKED,
PIPE_FORMAT_R8_G8B8_420_UNORM,
PIPE_FORMAT_R8_B8G8_420_UNORM,
PIPE_FORMAT_G8_B8R8_420_UNORM,
PIPE_FORMAT_R10G10B10_420_UNORM_PACKED,
PIPE_FORMAT_R10_G10B10_420_UNORM,
PIPE_FORMAT_R10_G10B10_422_UNORM,
PIPE_FORMAT_R8_G8_B8_420_UNORM,
@ -596,6 +603,8 @@ pipe_format_to_chroma_format(enum pipe_format format)
case PIPE_FORMAT_P016:
case PIPE_FORMAT_P030:
case PIPE_FORMAT_Y16_U16_V16_420_UNORM:
case PIPE_FORMAT_Y8U8V8_420_UNORM_PACKED:
case PIPE_FORMAT_Y10U10V10_420_UNORM_PACKED:
return PIPE_VIDEO_CHROMA_FORMAT_420;
case PIPE_FORMAT_UYVY:
case PIPE_FORMAT_VYUY: