Mesa (master): vulkan/wsi: Add callback to set ownership of buffer.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 27 18:12:23 UTC 2020
Module: Mesa
Branch: master
Commit: 9a61f2a8a9ca17e2d53dded9c1c490c890aa4a74
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a61f2a8a9ca17e2d53dded9c1c490c890aa4a74
Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date: Tue Mar 24 17:59:07 2020 +0100
vulkan/wsi: Add callback to set ownership of buffer.
For radv BO list pruning.
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Acked-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4306>
---
src/vulkan/wsi/wsi_common.c | 10 ++++++++++
src/vulkan/wsi/wsi_common.h | 16 ++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index d629ea339ac..44454190840 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -1098,6 +1098,11 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
if (result != VK_SUCCESS)
return result;
+ if (wsi->set_memory_ownership) {
+ VkDeviceMemory mem = swapchain->get_wsi_image(swapchain, *pImageIndex)->memory;
+ wsi->set_memory_ownership(swapchain->device, mem, true);
+ }
+
if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
wsi->signal_semaphore_for_memory != NULL) {
struct wsi_image *image =
@@ -1219,6 +1224,11 @@ wsi_common_queue_present(const struct wsi_device *wsi,
if (result != VK_SUCCESS)
goto fail_present;
+ if (wsi->set_memory_ownership) {
+ VkDeviceMemory mem = swapchain->get_wsi_image(swapchain, image_index)->memory;
+ wsi->set_memory_ownership(swapchain->device, mem, false);
+ }
+
fail_present:
if (pPresentInfo->pResults != NULL)
pPresentInfo->pResults[i] = result;
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 92121be8bda..99ccdf84cde 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -127,6 +127,22 @@ struct wsi_device {
VkFence fence,
VkDeviceMemory memory);
+ /*
+ * This sets the ownership for a WSI memory object:
+ *
+ * The ownership is true if and only if the application is allowed to submit
+ * command buffers that reference the buffer.
+ *
+ * This can be used to prune BO lists without too many adverse affects on
+ * implicit sync.
+ *
+ * Side note: care needs to be taken for internally delayed submissions wrt
+ * timeline semaphores.
+ */
+ void (*set_memory_ownership)(VkDevice device,
+ VkDeviceMemory memory,
+ VkBool32 ownership);
+
#define WSI_CB(cb) PFN_vk##cb cb
WSI_CB(AllocateMemory);
WSI_CB(AllocateCommandBuffers);
More information about the mesa-commit
mailing list