From d2c8593b2e618217cf727f979324c24446a87c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 17 Apr 2024 18:45:34 +0200 Subject: [PATCH] vkswapper: choose color space according with format The swapper surfaces contains the color space for each supported format. Instead of hard coding the color space, it returns the value associated with the negotiated vulkan format. Part-of: --- .../gst-libs/gst/vulkan/gstvkswapper.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkswapper.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkswapper.c index 1c94aa939c..6fd459cffd 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkswapper.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkswapper.c @@ -178,8 +178,18 @@ _get_function_table (GstVulkanSwapper * swapper) } static VkColorSpaceKHR -_vk_color_space_from_video_info (GstVideoInfo * v_info) +_vk_color_space_from_vk_format (GstVulkanSwapper * swapper, VkFormat format) { + GstVulkanSwapperPrivate *priv = GET_PRIV (swapper); + int i; + + for (i = 0; i < priv->n_surf_formats; i++) { + if (format != priv->surf_formats[i].format) + continue; + return priv->surf_formats[i].colorSpace; + } + + GST_WARNING_OBJECT (swapper, "unsupported format for swapper's colospaces"); return VK_COLORSPACE_SRGB_NONLINEAR_KHR; } @@ -790,7 +800,7 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps, } format = gst_vulkan_format_from_video_info (&priv->v_info, 0); - color_space = _vk_color_space_from_video_info (&priv->v_info); + color_space = _vk_color_space_from_vk_format (swapper, format); if ((priv->surf_props.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) != 0) {