Mesa (main): vulkan/wsi: Add signal_fence/semaphore_for_image helpers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed May 4 22:40:53 UTC 2022
Module: Mesa
Branch: main
Commit: 6214251c03cd00e79af7c4d8e90a180d733f75fa
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6214251c03cd00e79af7c4d8e90a180d733f75fa
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Mon Mar 15 12:04:56 2021 -0500
vulkan/wsi: Add signal_fence/semaphore_for_image helpers
These operations are about to get a bit more complex so let's add a
couple nice helpers to keep things clean.
Reviewed-by: Simon Ser <contact at emersion.fr>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16333>
---
src/vulkan/wsi/wsi_common.c | 75 +++++++++++++++++++++++++++++----------------
1 file changed, 49 insertions(+), 26 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 60db4cb00a0..16f2de21921 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -816,6 +816,40 @@ wsi_AcquireNextImageKHR(VkDevice _device,
pImageIndex);
}
+static VkResult
+wsi_signal_semaphore_for_image(struct vk_device *device,
+ const struct wsi_swapchain *chain,
+ const struct wsi_image *image,
+ VkSemaphore _semaphore)
+{
+ VK_FROM_HANDLE(vk_semaphore, semaphore, _semaphore);
+
+ if (!chain->wsi->signal_fence_with_memory)
+ return VK_SUCCESS;
+
+ vk_semaphore_reset_temporary(device, semaphore);
+ return device->create_sync_for_memory(device, image->memory,
+ false /* signal_memory */,
+ &semaphore->temporary);
+}
+
+static VkResult
+wsi_signal_fence_for_image(struct vk_device *device,
+ const struct wsi_swapchain *chain,
+ const struct wsi_image *image,
+ VkFence _fence)
+{
+ VK_FROM_HANDLE(vk_fence, fence, _fence);
+
+ if (!chain->wsi->signal_fence_with_memory)
+ return VK_SUCCESS;
+
+ vk_fence_reset_temporary(device, fence);
+ return device->create_sync_for_memory(device, image->memory,
+ false /* signal_memory */,
+ &fence->temporary);
+}
+
VkResult
wsi_common_acquire_next_image2(const struct wsi_device *wsi,
VkDevice _device,
@@ -835,34 +869,23 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
wsi->set_memory_ownership(swapchain->device, mem, true);
}
- if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
- wsi->signal_semaphore_with_memory) {
- VK_FROM_HANDLE(vk_semaphore, semaphore, pAcquireInfo->semaphore);
- struct wsi_image *image =
- swapchain->get_wsi_image(swapchain, *pImageIndex);
-
- vk_semaphore_reset_temporary(device, semaphore);
- VkResult lresult =
- device->create_sync_for_memory(device, image->memory,
- false /* signal_memory */,
- &semaphore->temporary);
- if (lresult != VK_SUCCESS)
- return lresult;
+ struct wsi_image *image =
+ swapchain->get_wsi_image(swapchain, *pImageIndex);
+
+ if (pAcquireInfo->semaphore != VK_NULL_HANDLE) {
+ VkResult signal_result =
+ wsi_signal_semaphore_for_image(device, swapchain, image,
+ pAcquireInfo->semaphore);
+ if (signal_result != VK_SUCCESS)
+ return signal_result;
}
- if (pAcquireInfo->fence != VK_NULL_HANDLE &&
- wsi->signal_fence_with_memory) {
- VK_FROM_HANDLE(vk_fence, fence, pAcquireInfo->fence);
- struct wsi_image *image =
- swapchain->get_wsi_image(swapchain, *pImageIndex);
-
- vk_fence_reset_temporary(device, fence);
- VkResult lresult =
- device->create_sync_for_memory(device, image->memory,
- false /* signal_memory */,
- &fence->temporary);
- if (lresult != VK_SUCCESS)
- return lresult;
+ if (pAcquireInfo->fence != VK_NULL_HANDLE) {
+ VkResult signal_result =
+ wsi_signal_fence_for_image(device, swapchain, image,
+ pAcquireInfo->fence);
+ if (signal_result != VK_SUCCESS)
+ return signal_result;
}
return result;
More information about the mesa-commit
mailing list