mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 05:12:09 +00:00
vulkan: add a timeline semaphore per image
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5079>
This commit is contained in:
parent
964aec54b4
commit
c83c508c5e
3 changed files with 50 additions and 0 deletions
|
@ -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;
|
||||
|
||||
/* <private> */
|
||||
gpointer _reserved [GST_PADDING];
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue