vkdevice: fine grained vulkan video extensions detection

The Vulkan Video extensions can be available, according to the specification,
since Vulkan 1.1, but with other extensions dependencies. That's why this patch
adds a field in the extension structure, which represents the extension
dependency that the specified extension requires. And they are specified by
Vulkan Video extensions.

This allow to have a single function to check if the extension can be enabled
both by optional extensions and video extensions.

Regardless that video extension can be loaded since Vulkan 1.1, they are rather
loaded since Vulkan 1.3, when synchronization2 was promoted, so it isn't
checked as video_queue dependency.

Finally, this patch checks for each guard symbol.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9492>
This commit is contained in:
Víctor Manuel Jáquez Leal 2025-07-31 13:19:13 +02:00 committed by GStreamer Marge Bot
parent 80da022590
commit f3f319a630

View File

@ -191,6 +191,8 @@ struct extension
/* the Vulkan API version that the extension has been promoted to core and
* does not need explicit enabling */
guint promoted_api_version;
/* other extension in which this depend on */
const char *dependency;
};
#define NEVER_VK_VERSION VK_MAKE_VERSION (999, 0, 0)
@ -206,35 +208,26 @@ can_enable_api_version (const struct extension *extension,
VK_VERSION_PATCH (extension->promoted_api_version)))
return FALSE;
return gst_vulkan_physical_device_check_api_version (phy_dev,
VK_VERSION_MAJOR (extension->min_api_version),
VK_VERSION_MINOR (extension->min_api_version),
VK_VERSION_PATCH (extension->min_api_version));
}
#define OPTIONAL_EXTENSION_VERSION(name, min, promoted) \
{ name, can_enable_api_version, min, promoted, }
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
static gboolean
can_enable_video_queue (const struct extension *extension,
GstVulkanPhysicalDevice * phy_dev)
{
if (gst_vulkan_physical_device_check_api_version (phy_dev, 1, 3, 0))
if (gst_vulkan_physical_device_check_api_version (phy_dev,
VK_VERSION_MAJOR (extension->min_api_version),
VK_VERSION_MINOR (extension->min_api_version),
VK_VERSION_PATCH (extension->min_api_version))) {
if (extension->dependency) {
return gst_vulkan_physical_device_get_extension_info (phy_dev,
extension->dependency, NULL);
}
return TRUE;
#if defined(VK_KHR_synchronization2)
if (gst_vulkan_physical_device_check_api_version (phy_dev, 1, 1, 0)
&& gst_vulkan_physical_device_get_extension_info (phy_dev,
VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, NULL))
return TRUE;
#endif
}
return FALSE;
}
#define OPTIONAL_VIDEO_EXTENSION(name) \
{ name, can_enable_video_queue, VK_MAKE_VERSION (1, 1, 0), NEVER_VK_VERSION, }
#define OPTIONAL_EXTENSION_VERSION(name, min, promoted) \
{ name, can_enable_api_version, min, promoted, NULL, }
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
#define OPTIONAL_VIDEO_EXTENSION(name, dep) \
{ name, can_enable_api_version, VK_MAKE_VERSION (1, 3, 0), \
NEVER_VK_VERSION, dep, }
#endif
static const struct extension optional_extensions[] = {
@ -251,17 +244,40 @@ static const struct extension optional_extensions[] = {
VK_MAKE_VERSION (1, 1, 0), VK_MAKE_VERSION (1, 3, 0)),
#endif
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_QUEUE_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME),
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME),
#if defined(VK_KHR_video_maintenance1)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_MAINTENANCE_1_EXTENSION_NAME),
#endif
# if defined(VK_KHR_video_queue)
/* synchronization2 was promoted in 1.3 */
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_QUEUE_EXTENSION_NAME,
/* VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME */ NULL),
#endif
# if defined(VK_KHR_video_decode_queue)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_decode_h264)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_decode_h265)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_encode_queue)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_encode_h264)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_encode_h265)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME,
VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME),
# endif
# if defined(VK_KHR_video_maintenance1)
OPTIONAL_VIDEO_EXTENSION (VK_KHR_VIDEO_MAINTENANCE_1_EXTENSION_NAME,
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME),
# endif
#endif /* GST_VULKAN_HAVE_VIDEO_EXTENSIONS */
};
static void