aboutsummaryrefslogtreecommitdiffstats
path: root/src/vulkan/wsi
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-12-04 12:47:31 -0600
committerJason Ekstrand <[email protected]>2019-12-06 19:58:07 +0000
commit778b51f491cfe56da463195e1392293379b9fe26 (patch)
treed0960dba56f2bbbb0e597a158597f89e401146f9 /src/vulkan/wsi
parent48e23a64067ab7f775b1c4e2966041fbbf9d42e3 (diff)
vulkan/wsi: Add a hooks for signaling semaphores and fences
Reviewed-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/vulkan/wsi')
-rw-r--r--src/vulkan/wsi/wsi_common.c23
-rw-r--r--src/vulkan/wsi/wsi_common.h16
2 files changed, 38 insertions, 1 deletions
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 3abffe3dee7..65ab543cc5d 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -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
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index d15dea7b0eb..704c1abd809 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -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);