From f20ee2806eb9ea4a162fa1f2387e2f0174cd421d Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 27 May 2025 09:49:22 +0200 Subject: [PATCH] util/format: Add subsampling info to our YUV-as-RGB format names This will allow for more autogen and is good to have regardless, because it makes it clear what the subsampling is when looking at the name. Signed-off-by: Boris Brezillon Part-of: --- src/util/format/u_format.yaml | 27 +++++++---- src/util/format/u_format_table.py | 16 +++---- src/util/format/u_format_yuv.c | 74 +++++++++++++++++++------------ src/util/format/u_format_yuv.h | 74 +++++++++++++++++++------------ 4 files changed, 118 insertions(+), 73 deletions(-) diff --git a/src/util/format/u_format.yaml b/src/util/format/u_format.yaml index 767d884c52b..7550aa22016 100644 --- a/src/util/format/u_format.yaml +++ b/src/util/format/u_format.yaml @@ -731,49 +731,57 @@ swizzles: [X, Y, Z, 1] # same subsampling but with rgb channels -- name: R8G8_B8G8_UNORM +- name: R8G8_B8G8_422_UNORM + alias: R8G8_B8G8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [X, Y, Z, 1] -- name: G8R8_G8B8_UNORM +- name: G8R8_G8B8_422_UNORM + alias: G8R8_G8B8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [X, Y, Z, 1] -- name: G8R8_B8R8_UNORM +- name: G8R8_B8R8_422_UNORM + alias: G8R8_B8R8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [Z, Y, X, 1] -- name: R8G8_R8B8_UNORM +- name: R8G8_R8B8_422_UNORM + alias: R8G8_R8B8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [Z, Y, X, 1] -- name: B8R8_G8R8_UNORM +- name: B8R8_G8R8_422_UNORM + alias: B8R8_G8R8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [Y, X, Z, 1] -- name: R8B8_R8G8_UNORM +- name: R8B8_R8G8_422_UNORM + alias: R8B8_R8G8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [Y, X, Z, 1] -- name: G8B8_G8R8_UNORM +- name: G8B8_G8R8_422_UNORM + alias: G8B8_G8R8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} channels: [UN8, UN8, UN8, UN8] swizzles: [X, Y, Z, 1] -- name: B8G8_R8G8_UNORM +- name: B8G8_R8G8_422_UNORM + alias: B8G8_R8G8_UNORM layout: subsampled colorspace: RGB block: {width: 2, height: 1, depth: 1} @@ -2094,7 +2102,8 @@ block: {width: 1, height: 1, depth: 1} channels: [UN8] swizzles: [X, Y, Z, W] -- name: R8_G8_B8_UNORM +- name: R8_G8_B8_444_UNORM + alias: R8_G8_B8_UNORM layout: planar3 colorspace: RGB block: {width: 1, height: 1, depth: 1} diff --git a/src/util/format/u_format_table.py b/src/util/format/u_format_table.py index 1913e526cda..4644fc6794d 100644 --- a/src/util/format/u_format_table.py +++ b/src/util/format/u_format_table.py @@ -100,13 +100,13 @@ def has_access(format): 'u16y16v16a16_444_unorm', 'x8y8u8v8_444_unorm', 'a8y8u8v8_444_unorm', - 'r8g8_r8b8_unorm', - 'r8b8_r8g8_unorm', - 'g8r8_b8r8_unorm', - 'b8r8_g8r8_unorm', - 'g8r8_g8b8_unorm', - 'g8b8_g8r8_unorm', - 'b8g8_r8g8_unorm', + 'r8g8_r8b8_422_unorm', + 'r8b8_r8g8_422_unorm', + 'g8r8_b8r8_422_unorm', + 'b8r8_g8r8_422_unorm', + 'g8r8_g8b8_422_unorm', + 'g8b8_g8r8_422_unorm', + 'b8g8_r8g8_422_unorm', 'x6g10_x6b10x6r10_420_unorm', 'x4g12_x4b12x4r12_420_unorm', 'y8_400_unorm', @@ -134,7 +134,7 @@ def has_access(format): 'r8_g8_b8_420_unorm', 'r8_b8_g8_420_unorm', 'g8_b8_r8_420_unorm', - 'r8_g8_b8_unorm', + 'r8_g8_b8_444_unorm', 'r8g8b8_420_unorm_packed', 'r10g10b10_420_unorm_packed', 'y8_unorm', diff --git a/src/util/format/u_format_yuv.c b/src/util/format/u_format_yuv.c index 376d82df675..b0ff7ab63bd 100644 --- a/src/util/format/u_format_yuv.c +++ b/src/util/format/u_format_yuv.c @@ -39,9 +39,11 @@ void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_r8g8_b8g8_422_unorm_unpack_rgba_float(void *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -93,9 +95,11 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned d void -util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_r8g8_b8g8_422_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -147,9 +151,11 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsign void -util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_stride, - const float *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_r8g8_b8g8_422_unorm_pack_rgba_float(uint8_t *restrict dst_row, + unsigned dst_stride, + const float *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -196,9 +202,11 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned void -util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_r8g8_b8g8_422_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -245,8 +253,9 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned void -util_format_r8g8_b8g8_unorm_fetch_rgba(void *restrict in_dst, const uint8_t *restrict src, - unsigned i, ASSERTED unsigned j) +util_format_r8g8_b8g8_422_unorm_fetch_rgba(void *restrict in_dst, + const uint8_t *restrict src, + unsigned i, ASSERTED unsigned j) { float *dst = in_dst; @@ -261,9 +270,11 @@ util_format_r8g8_b8g8_unorm_fetch_rgba(void *restrict in_dst, const uint8_t *res void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_g8r8_g8b8_422_unorm_unpack_rgba_float(void *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -315,9 +326,11 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned d void -util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_g8r8_g8b8_422_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -369,9 +382,11 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsign void -util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_stride, - const float *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_g8r8_g8b8_422_unorm_pack_rgba_float(uint8_t *restrict dst_row, + unsigned dst_stride, + const float *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -418,9 +433,11 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned void -util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height) +util_format_g8r8_g8b8_422_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y; @@ -467,8 +484,9 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned void -util_format_g8r8_g8b8_unorm_fetch_rgba(void *restrict in_dst, const uint8_t *restrict src, - unsigned i, ASSERTED unsigned j) +util_format_g8r8_g8b8_422_unorm_fetch_rgba(void *restrict in_dst, + const uint8_t *restrict src, + unsigned i, ASSERTED unsigned j) { float *dst = in_dst; diff --git a/src/util/format/u_format_yuv.h b/src/util/format/u_format_yuv.h index bdb5ab52870..fa8f336f383 100644 --- a/src/util/format/u_format_yuv.h +++ b/src/util/format/u_format_yuv.h @@ -255,51 +255,69 @@ util_format_y8v8y8u8_422_unorm_fetch_rgba(void *restrict dst, unsigned i, unsigned j); void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_r8g8_b8g8_422_unorm_unpack_rgba_float(void *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_r8g8_b8g8_422_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_stride, - const float *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_r8g8_b8g8_422_unorm_pack_rgba_float(uint8_t *restrict dst_row, + unsigned dst_stride, + const float *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_r8g8_b8g8_422_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_r8g8_b8g8_unorm_fetch_rgba(void *restrict dst, const uint8_t *restrict src, - unsigned i, unsigned j); +util_format_r8g8_b8g8_422_unorm_fetch_rgba(void *restrict dst, + const uint8_t *restrict src, + unsigned i, unsigned j); void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(void *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_g8r8_g8b8_422_unorm_unpack_rgba_float(void *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_g8r8_g8b8_422_unorm_unpack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_stride, - const float *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_g8r8_g8b8_422_unorm_pack_rgba_float(uint8_t *restrict dst_row, + unsigned dst_stride, + const float *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride, - const uint8_t *restrict src_row, unsigned src_stride, - unsigned width, unsigned height); +util_format_g8r8_g8b8_422_unorm_pack_rgba_8unorm(uint8_t *restrict dst_row, + unsigned dst_stride, + const uint8_t *restrict src_row, + unsigned src_stride, + unsigned width, unsigned height); void -util_format_g8r8_g8b8_unorm_fetch_rgba(void *restrict dst, const uint8_t *restrict src, - unsigned i, unsigned j); +util_format_g8r8_g8b8_422_unorm_fetch_rgba(void *restrict dst, + const uint8_t *restrict src, + unsigned i, unsigned j); #endif /* U_FORMAT_YUV_H_ */