aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-05-05 13:36:00 +0200
committerSimon Ser <contact@emersion.fr>2023-05-24 08:58:59 +0000
commit16dea12dae0bf3207741049c5a6dc6d4076507c0 (patch)
treef0b74428589e3c0ded31eac326b88280c51e17fd /render
parenta682fa6c21b9d80e8700fb049e61c8dce2b65fb8 (diff)
render/vulkan: add more YCbCr formats
The Vulkan spec states: > For the purposes of range expansion and Y′CBCR model conversion, > the R and B components contain color difference (chroma) values > and the G component contains luma. The equations below that sentence also help understand the mapping.
Diffstat (limited to 'render')
-rw-r--r--render/vulkan/pixel_format.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/render/vulkan/pixel_format.c b/render/vulkan/pixel_format.c
index 01d69db3..e633c5c1 100644
--- a/render/vulkan/pixel_format.c
+++ b/render/vulkan/pixel_format.c
@@ -145,11 +145,46 @@ static const struct wlr_vk_format formats[] = {
#endif
// YCbCr formats
+ // R -> V, G -> Y, B -> U
+ // 420 -> 2x2 subsampled, 422 -> 2x1 subsampled, 444 -> non-subsampled
+ {
+ .drm = DRM_FORMAT_UYVY,
+ .vk = VK_FORMAT_B8G8R8G8_422_UNORM,
+ .is_ycbcr = true,
+ },
+ {
+ .drm = DRM_FORMAT_YUYV,
+ .vk = VK_FORMAT_G8B8G8R8_422_UNORM,
+ .is_ycbcr = true,
+ },
{
.drm = DRM_FORMAT_NV12,
.vk = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM,
.is_ycbcr = true,
},
+ {
+ .drm = DRM_FORMAT_NV16,
+ .vk = VK_FORMAT_G8_B8R8_2PLANE_422_UNORM,
+ .is_ycbcr = true,
+ },
+ {
+ .drm = DRM_FORMAT_YUV420,
+ .vk = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
+ .is_ycbcr = true,
+ },
+ {
+ .drm = DRM_FORMAT_YUV422,
+ .vk = VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM,
+ .is_ycbcr = true,
+ },
+ {
+ .drm = DRM_FORMAT_YUV444,
+ .vk = VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM,
+ .is_ycbcr = true,
+ },
+ // TODO: add 10, 12 and 16 bit formats
+ // TODO: add DRM_FORMAT_NV24/VK_FORMAT_G8_B8R8_2PLANE_444_UNORM (requires
+ // Vulkan 1.3 or VK_EXT_ycbcr_2plane_444_formats)
};
const struct wlr_vk_format *vulkan_get_format_list(size_t *len) {