vulkan/wsi: Add a hooks for signaling semaphores and fences
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 4 Dec 2019 18:47:31 +0000 (12:47 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 6 Dec 2019 19:58:07 +0000 (19:58 +0000)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h

index 3abffe3dee70df38b7fc88b021673ae119542af2..65ab543cc5d77cb45d997eb53f07e49a876d0d4e 100644 (file)
@@ -1004,7 +1004,28 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
 {
    WSI_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain);
 
-   return swapchain->acquire_next_image(swapchain, pAcquireInfo, pImageIndex);
+   VkResult result = swapchain->acquire_next_image(swapchain, pAcquireInfo,
+                                                   pImageIndex);
+   if (result != VK_SUCCESS)
+      return result;
+
+   if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
+       wsi->signal_semaphore_for_memory != NULL) {
+      struct wsi_image *image =
+         swapchain->get_wsi_image(swapchain, *pImageIndex);
+      wsi->signal_semaphore_for_memory(device, pAcquireInfo->semaphore,
+                                       image->memory);
+   }
+
+   if (pAcquireInfo->fence != VK_NULL_HANDLE &&
+       wsi->signal_fence_for_memory != NULL) {
+      struct wsi_image *image =
+         swapchain->get_wsi_image(swapchain, *pImageIndex);
+      wsi->signal_fence_for_memory(device, pAcquireInfo->fence,
+                                   image->memory);
+   }
+
+   return VK_SUCCESS;
 }
 
 VkResult
index d15dea7b0eb97c59ff2abad85800ea42266248a3..704c1abd809fda906f90f384851c2273145f9085 100644 (file)
@@ -130,6 +130,22 @@ struct wsi_device {
 
    uint64_t (*image_get_modifier)(VkImage image);
 
+   /* Signals the semaphore such that any wait on the semaphore will wait on
+    * any reads or writes on the give memory object.  This is used to
+    * implement the semaphore signal operation in vkAcquireNextImage.
+    */
+   void (*signal_semaphore_for_memory)(VkDevice device,
+                                       VkSemaphore semaphore,
+                                       VkDeviceMemory memory);
+
+   /* Signals the fence such that any wait on the fence will wait on any reads
+    * or writes on the give memory object.  This is used to implement the
+    * semaphore signal operation in vkAcquireNextImage.
+    */
+   void (*signal_fence_for_memory)(VkDevice device,
+                                   VkFence fence,
+                                   VkDeviceMemory memory);
+
 #define WSI_CB(cb) PFN_vk##cb cb
    WSI_CB(AllocateMemory);
    WSI_CB(AllocateCommandBuffers);