From a9c24ff653fcce36f575025e181c14f461918fc2 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 4 Sep 2023 20:05:28 +0200 Subject: [PATCH] multi-texture-format: Add P010 YCbCr format It's the 10 bit equivalent to NV12 and uses the same layout as P016, i.e. 16 bit components with the lowest 6 bits set to 0 (padding), allowing us to use 16 bit "subformats". Thus adding support is quite trivial as we can reuse the NV12 shader. The format is widely supported in decoding and display hardware (on Intel since Kaby Lake), as well as modern codecs (AV1, VP9, HEVC) and has visible quality advantages over NV12. Note that the additional colors are lost if composited to a 8 bit RGB framebuffer. Switching between direct scanout and compositing can thus cause quality differences. This is no new phenomena, however, as the same is the case already for e.g. GL clients using 10 bit formats - including video players. Also note that P012 and P016 could trivially added as well - it's not done here as they are uncommen and thus hard to test. Part-of: --- src/common/meta-cogl-drm-formats.h | 1 + src/compositor/meta-multi-texture-format.c | 10 ++++++++++ src/meta/meta-multi-texture-format.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/common/meta-cogl-drm-formats.h b/src/common/meta-cogl-drm-formats.h index efa20662a..00a5349ce 100644 --- a/src/common/meta-cogl-drm-formats.h +++ b/src/common/meta-cogl-drm-formats.h @@ -62,6 +62,7 @@ static const CoglDrmFormatMap meta_cogl_drm_format_map[] = { { DRM_FORMAT_ABGR16161616F, COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, { DRM_FORMAT_YUYV, COGL_PIXEL_FORMAT_ANY, META_MULTI_TEXTURE_FORMAT_YUYV }, { DRM_FORMAT_NV12, COGL_PIXEL_FORMAT_ANY, META_MULTI_TEXTURE_FORMAT_NV12 }, + { DRM_FORMAT_P010, COGL_PIXEL_FORMAT_ANY, META_MULTI_TEXTURE_FORMAT_P010 }, { DRM_FORMAT_YUV420, COGL_PIXEL_FORMAT_ANY, META_MULTI_TEXTURE_FORMAT_YUV420 }, #elif G_BYTE_ORDER == G_BIG_ENDIAN { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_RGBX_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, diff --git a/src/compositor/meta-multi-texture-format.c b/src/compositor/meta-multi-texture-format.c index 985d5b095..9f338e584 100644 --- a/src/compositor/meta-multi-texture-format.c +++ b/src/compositor/meta-multi-texture-format.c @@ -135,6 +135,16 @@ static MetaMultiTextureFormatInfo multi_format_table[] = { .rgb_shader = y_uv_shader, .snippet_once = G_ONCE_INIT, }, + [META_MULTI_TEXTURE_FORMAT_P010] = { + .name = "P010", + .n_planes = 2, + .subformats = { COGL_PIXEL_FORMAT_G_16, COGL_PIXEL_FORMAT_RG_1616 }, + .plane_indices = { 0, 1 }, + .hsub = { 1, 2 }, + .vsub = { 1, 2 }, + .rgb_shader = y_uv_shader, + .snippet_once = G_ONCE_INIT, + }, /* 3 plane YUV */ [META_MULTI_TEXTURE_FORMAT_YUV420] = { .name = "YUV420", diff --git a/src/meta/meta-multi-texture-format.h b/src/meta/meta-multi-texture-format.h index 116261cdb..1bb752259 100644 --- a/src/meta/meta-multi-texture-format.h +++ b/src/meta/meta-multi-texture-format.h @@ -37,6 +37,7 @@ typedef enum _MetaMultiTextureFormat META_MULTI_TEXTURE_FORMAT_SIMPLE, META_MULTI_TEXTURE_FORMAT_YUYV, META_MULTI_TEXTURE_FORMAT_NV12, + META_MULTI_TEXTURE_FORMAT_P010, META_MULTI_TEXTURE_FORMAT_YUV420, } MetaMultiTextureFormat;