From 93364189d06484f256e4ddede507506afc83c5f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@igalia.com>
Date: Mon, 3 Mar 2025 11:30:38 +0100
Subject: [PATCH] vulkan/operation: fix timeline semaphore extension detection

As for synchronization2, the timeline semaphore has been
been promoted in 1.2 and does not have to be enabled explicitely.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8554>
---
 .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c   | 3 ++-
 .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c     | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c
index 71c0bbe3c6..02f3c83aeb 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c
@@ -167,7 +167,8 @@ _vk_image_mem_new_alloc_with_image_info (GstAllocator * allocator,
   mem->image = image;
 
 #if defined(VK_KHR_timeline_semaphore)
-  if (gst_vulkan_device_is_extension_enabled (device,
+  if (gst_vulkan_physical_device_check_api_version (device->physical_device, 1,
+          2, 0) || gst_vulkan_device_is_extension_enabled (device,
           VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME)) {
     VkSemaphoreTypeCreateInfo semaphore_type_info = {
       .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c
index edfb0720bf..28962c86b0 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c
@@ -197,7 +197,10 @@ gst_vulkan_operation_constructed (GObject * object)
   priv->has_video_maintenance1 = gst_vulkan_video_has_maintenance1 (device);
 #endif
 #if defined(VK_KHR_timeline_semaphore)
-  priv->has_timeline = gst_vulkan_device_is_extension_enabled (device,
+  priv->has_timeline =
+      gst_vulkan_physical_device_check_api_version (device->physical_device, 1,
+      2, 0)
+      || gst_vulkan_device_is_extension_enabled (device,
       VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
 #endif
 #endif