diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkbarrier.h b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkbarrier.h index 56c8fb3d9c..81fc15602d 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkbarrier.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkbarrier.h @@ -61,6 +61,8 @@ typedef enum * @queue: the #GstVulkanQueue this barrier is to execute with * @pipeline_stages: the stages in the graphics pipeline to execute the barrier * @access_flags: access flags + * @semaphore: timeline semaphore + * @semaphore_value: current value of the timeline semaphore * * Since: 1.18 */ @@ -72,6 +74,23 @@ struct _GstVulkanBarrierMemoryInfo guint64 pipeline_stages; guint64 access_flags; + /** + * GstVulkanBarrierMemoryInfo.semaphore: + * + * Timeline semaphore + * + * Since: 1.24 + */ + VkSemaphore semaphore; + /** + * GstVulkanBarrierMemoryInfo.semaphore_value: + * + * Current value of the timeline semaphore + * + * Since: 1.24 + */ + guint64 semaphore_value; + /* */ gpointer _reserved [GST_PADDING]; }; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c index dcf6b7c12e..f3f7dde082 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c @@ -180,6 +180,9 @@ gst_vulkan_device_constructed (GObject * object) const char *optional_extensions[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, +#if defined(VK_KHR_timeline_semaphore) + VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, +#endif #if defined(VK_KHR_synchronization2) VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, #endif 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 8db32a6973..d58747d869 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c @@ -91,6 +91,8 @@ gst_vulkan_image_memory_init (GstVulkanImageMemory * mem, mem->barrier.parent.type = GST_VULKAN_BARRIER_TYPE_IMAGE; mem->barrier.parent.pipeline_stages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; mem->barrier.parent.access_flags = 0; + mem->barrier.parent.semaphore = VK_NULL_HANDLE; + mem->barrier.parent.semaphore_value = 0; mem->barrier.image_layout = VK_IMAGE_LAYOUT_UNDEFINED; /* *INDENT-OFF* */ mem->barrier.subresource_range = (VkImageSubresourceRange) { @@ -163,6 +165,27 @@ _vk_image_mem_new_alloc_with_image_info (GstAllocator * allocator, mem->create_info.pNext = NULL; mem->image = image; +#if defined(VK_KHR_timeline_semaphore) + if (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, + .semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE, + .initialValue = 0, + }; + VkSemaphoreCreateInfo semaphore_create_info = { + .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, + .pNext = &semaphore_type_info, + }; + + err = vkCreateSemaphore (device->device, &semaphore_create_info, NULL, + &mem->barrier.parent.semaphore); + if (gst_vulkan_error_to_g_error (err, &error, "vkCreateSemaphore") < 0) + goto vk_error; + } +#endif + + err = vkGetPhysicalDeviceImageFormatProperties (gpu, image_info->format, VK_IMAGE_TYPE_2D, image_info->tiling, image_info->usage, 0, &mem->format_properties); @@ -371,6 +394,11 @@ _vk_image_mem_free (GstAllocator * allocator, GstMemory * memory) if (mem->vk_mem) gst_memory_unref ((GstMemory *) mem->vk_mem); + if (mem->barrier.parent.semaphore) { + vkDestroySemaphore (mem->device->device, mem->barrier.parent.semaphore, + NULL); + } + if (mem->notify) mem->notify (mem->user_data);