vkvideo: add video_maintenance1 check
authorStéphane Cerveau <scerveau@igalia.com>
Mon, 9 Dec 2024 13:45:01 +0000 (14:45 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 10 Dec 2024 15:52:21 +0000 (15:52 +0000)
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>

subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c
subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideo-private.c
subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideo-private.h

index edd1ba4003fb7804b6ac89ced1175fe6b02e4bc7..7134c7b8d34f915f949063c828b74d215ecfc6a0 100644 (file)
@@ -23,7 +23,7 @@
 #endif
 
 #include "gstvkoperation.h"
-#include "gstvkphysicaldevice-private.h"
+#include "gstvkvideo-private.h"
 
 /**
  * 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
 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,
       VK_KHR_VIDEO_QUEUE_EXTENSION_NAME);
 #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)
   priv->has_timeline = gst_vulkan_device_is_extension_enabled (device,
index 64a79bc9582b78370a9a25c2d58b6ae8d2542165..69bb5e638284f03fcaa1ac557f895b3ee79293ca 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include "gstvkvideo-private.h"
+#include "gstvkphysicaldevice-private.h"
 #include "gstvkinstance.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 (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,
       &vk_session);
   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,
       &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;
+}
index 3ae6a2f6003fe460ab9e0530ddf5ebfba4d40c52..a1cbddc8f4be5eca64b69c940fd14a0c8b5f6edf 100644 (file)
@@ -97,4 +97,6 @@ GstVulkanImageView *    gst_vulkan_video_image_create_view     (GstBuffer * buf,
                                                                 gboolean is_out,
                                                                 GstVulkanHandle * sampler);
 
+gboolean                gst_vulkan_video_has_maintenance1      (GstVulkanDevice * device);
+
 G_END_DECLS