vkvideo: add video_maintenance1 check

Add gst_vulkan_video_maintenance1_supported
to check if the video session needs
VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8112>
This commit is contained in:
Stéphane Cerveau 2024-12-09 14:45:01 +01:00 committed by GStreamer Marge Bot
parent 4aa6b35639
commit fd1946c26b
3 changed files with 31 additions and 29 deletions

View file

@ -23,7 +23,7 @@
#endif #endif
#include "gstvkoperation.h" #include "gstvkoperation.h"
#include "gstvkphysicaldevice-private.h" #include "gstvkvideo-private.h"
/** /**
* SECTION:vkoperation * SECTION:vkoperation
@ -146,34 +146,7 @@ gst_vulkan_operation_get_property (GObject * object, guint prop_id,
} }
} }
static gboolean
_video_maintenance1_supported (GstVulkanOperation * self)
{
#if defined(VK_KHR_video_maintenance1)
GstVulkanOperationPrivate *priv;
GstVulkanDevice *device;
const VkPhysicalDeviceFeatures2 *features;
const VkBaseOutStructure *iter;
g_return_val_if_fail (GST_IS_VULKAN_OPERATION (self), FALSE);
priv = GET_PRIV (self);
device = priv->cmd_pool->queue->device;
features = gst_vulkan_physical_device_get_features (device->physical_device);
for (iter = (const VkBaseOutStructure *) features; iter; iter = iter->pNext) {
if (iter->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR) {
const VkPhysicalDeviceVideoMaintenance1FeaturesKHR *video_maintenance1 =
(const VkPhysicalDeviceVideoMaintenance1FeaturesKHR *) iter;
return video_maintenance1->videoMaintenance1;
}
}
#endif
return FALSE;
}
static void static void
gst_vulkan_operation_constructed (GObject * object) gst_vulkan_operation_constructed (GObject * object)
@ -215,7 +188,7 @@ gst_vulkan_operation_constructed (GObject * object)
priv->has_video = gst_vulkan_device_is_extension_enabled (device, priv->has_video = gst_vulkan_device_is_extension_enabled (device,
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME); VK_KHR_VIDEO_QUEUE_EXTENSION_NAME);
#endif #endif
priv->has_video_maintenance1 = _video_maintenance1_supported (self); priv->has_video_maintenance1 = gst_vulkan_video_has_maintenance1 (device);
#if defined(VK_KHR_timeline_semaphore) #if defined(VK_KHR_timeline_semaphore)
priv->has_timeline = gst_vulkan_device_is_extension_enabled (device, priv->has_timeline = gst_vulkan_device_is_extension_enabled (device,

View file

@ -23,6 +23,7 @@
#endif #endif
#include "gstvkvideo-private.h" #include "gstvkvideo-private.h"
#include "gstvkphysicaldevice-private.h"
#include "gstvkinstance.h" #include "gstvkinstance.h"
#include <vk_video/vulkan_video_codecs_common.h> #include <vk_video/vulkan_video_codecs_common.h>
@ -114,6 +115,12 @@ gst_vulkan_video_session_create (GstVulkanVideoSession * session,
g_return_val_if_fail (vk, FALSE); g_return_val_if_fail (vk, FALSE);
g_return_val_if_fail (session_create, FALSE); g_return_val_if_fail (session_create, FALSE);
#if defined(VK_KHR_video_maintenance1)
if (gst_vulkan_video_has_maintenance1 (device)) {
session_create->flags |= VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR;
}
#endif
res = vk->CreateVideoSession (device->device, session_create, NULL, res = vk->CreateVideoSession (device->device, session_create, NULL,
&vk_session); &vk_session);
if (gst_vulkan_error_to_g_error (res, error, "vkCreateVideoSessionKHR") if (gst_vulkan_error_to_g_error (res, error, "vkCreateVideoSessionKHR")
@ -312,3 +319,23 @@ gst_vulkan_video_image_create_view (GstBuffer * buf, gboolean layered_dpb,
return gst_vulkan_get_or_create_image_view_with_info (vkmem, return gst_vulkan_get_or_create_image_view_with_info (vkmem,
&view_create_info); &view_create_info);
} }
gboolean
gst_vulkan_video_has_maintenance1 (GstVulkanDevice * device)
{
#if defined(VK_KHR_video_maintenance1)
const VkPhysicalDeviceFeatures2 *features;
const VkBaseOutStructure *iter;
features = gst_vulkan_physical_device_get_features (device->physical_device);
for (iter = (const VkBaseOutStructure *) features; iter; iter = iter->pNext) {
if (iter->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR) {
const VkPhysicalDeviceVideoMaintenance1FeaturesKHR *video_maintenance1 =
(const VkPhysicalDeviceVideoMaintenance1FeaturesKHR *) iter;
return video_maintenance1->videoMaintenance1;
}
}
#endif
return FALSE;
}

View file

@ -97,4 +97,6 @@ GstVulkanImageView * gst_vulkan_video_image_create_view (GstBuffer * buf,
gboolean is_out, gboolean is_out,
GstVulkanHandle * sampler); GstVulkanHandle * sampler);
gboolean gst_vulkan_video_has_maintenance1 (GstVulkanDevice * device);
G_END_DECLS G_END_DECLS