util/format: mark subsampled RGB formats as actually subsampled

This applies to all subsampled layouts, including the planar ones.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41151>
This commit is contained in:
Erik Faye-Lund 2026-04-22 09:50:42 +02:00 committed by Marge Bot
parent 22cf4f6742
commit c1934ddf65
2 changed files with 41 additions and 3 deletions

View file

@ -748,6 +748,7 @@
alias: R8G8_B8G8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [X, Y, Z, 1]
@ -755,6 +756,7 @@
alias: G8R8_G8B8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [X, Y, Z, 1]
@ -762,6 +764,7 @@
alias: G8R8_B8R8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [Z, Y, X, 1]
@ -769,6 +772,7 @@
alias: R8G8_R8B8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [Z, Y, X, 1]
@ -776,6 +780,7 @@
alias: B8R8_G8R8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [Y, X, Z, 1]
@ -783,6 +788,7 @@
alias: R8B8_R8G8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [Y, X, Z, 1]
@ -790,6 +796,7 @@
alias: G8B8_G8R8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [X, Y, Z, 1]
@ -797,6 +804,7 @@
alias: B8G8_R8G8_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN8, UN8, UN8, UN8]
swizzles: [X, Y, Z, 1]
@ -805,12 +813,14 @@
- name: R16G16_R16B16_422_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN16, UN16, UN16, UN16]
swizzles: [X, Y, Z, 1]
- name: X6R10X6G10_X6R10X6B10_422_UNORM
layout: subsampled
colorspace: RGB
subsampling: 422
block: {width: 2, height: 1, depth: 1}
channels: [UN16, UN16, UN16, UN16]
swizzles: [X, Y, Z, 1]
@ -2074,66 +2084,77 @@
- name: R8_G8B8_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: R8_B8G8_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: G8_B8R8_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: R8_G8B8_422_UNORM
layout: planar2
colorspace: RGB
subsampling: 422
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: R8_B8G8_422_UNORM
layout: planar2
colorspace: RGB
subsampling: 422
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: G8_B8R8_422_UNORM
layout: planar2
colorspace: RGB
subsampling: 422
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: R10_G10B10_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 4, height: 1, depth: 1}
channels: [UN40]
swizzles: [X, Y, Z, W]
- name: R10_G10B10_422_UNORM
layout: planar2
colorspace: RGB
subsampling: 422
block: {width: 4, height: 1, depth: 1}
channels: [UN40]
swizzles: [X, Y, Z, W]
- name: R8_G8_B8_420_UNORM
layout: planar3
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: R8_B8_G8_420_UNORM
layout: planar3
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: G8_B8_R8_420_UNORM
layout: planar3
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
@ -2141,18 +2162,21 @@
alias: R8_G8_B8_UNORM
layout: planar3
colorspace: RGB
subsampling: 444
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: X6G10_X6B10X6R10_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [X6, UN10]
swizzles: [X, Y, Z, W]
- name: X4G12_X4B12X4R12_420_UNORM
layout: planar2
colorspace: RGB
subsampling: 420
block: {width: 1, height: 1, depth: 1}
channels: [X4, UN12]
swizzles: [X, Y, Z, W]
@ -2161,18 +2185,21 @@
- name: G8_B8R8_444_UNORM
layout: planar2
colorspace: RGB
subsampling: 444
block: {width: 1, height: 1, depth: 1}
channels: [UN8]
swizzles: [X, Y, Z, W]
- name: X6G10_X6B10X6R10_444_UNORM
layout: planar2
colorspace: RGB
subsampling: 444
block: {width: 1, height: 1, depth: 1}
channels: [X6, UN10]
swizzles: [X, Y, Z, W]
- name: X4G12_X4B12X4R12_444_UNORM
layout: planar2
colorspace: RGB
subsampling: 444
block: {width: 1, height: 1, depth: 1}
channels: [X4, UN12]
swizzles: [X, Y, Z, W]
@ -2188,6 +2215,7 @@
- name: R8G8B8_420_UNORM_PACKED
layout: subsampled
colorspace: RGB
subsampling: 420
block: {width: 2, height: 2, depth: 1}
channels: [X48]
swizzles: [X, Y, Z, 1]
@ -2196,6 +2224,7 @@
- name: R10G10B10_420_UNORM_PACKED
layout: subsampled
colorspace: RGB
subsampling: 420
block: {width: 4, height: 2, depth: 1}
channels: [X120]
swizzles: [X, Y, Z, 1]

View file

@ -737,14 +737,23 @@ static bool
test_format_subsampling(const struct util_format_description *format_desc)
{
if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_YUV ||
(format_desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED &&
format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB)) {
/* subsampled non-RGB and YUV formats must specify a subsampling format */
format_desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED ||
format_desc->layout == UTIL_FORMAT_LAYOUT_PLANAR2 ||
format_desc->layout == UTIL_FORMAT_LAYOUT_PLANAR3) {
/* subsampled, planar and YUV formats must specify subsampling */
if (format_desc->subsampling == PIPE_VIDEO_CHROMA_FORMAT_NONE) {
fprintf(stderr, "%s is not subsampled, as it should be.\n",
format_desc->name);
return false;
}
} else {
/* other formats shouldn't have subsampling */
if (format_desc->subsampling != PIPE_VIDEO_CHROMA_FORMAT_NONE) {
fprintf(stderr, "%s is not subsampled, as it should be.\n",
format_desc->name);
return false;
}
}
return true;