Mesa (main): wsi: Always signal semaphores and fences in wsi_common_acquire_next_image

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 10 02:14:01 UTC 2022


Module: Mesa
Branch: main
Commit: b03216de9cc8a9d22db69bf96d82b1898806e7e8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b03216de9cc8a9d22db69bf96d82b1898806e7e8

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Thu May 19 19:33:01 2022 -0500

wsi: Always signal semaphores and fences in wsi_common_acquire_next_image

If the driver wants to do something special, it can reset the semaphore
or fence again and re-signal it.  Sure, that wastes a malloc/free but
this is the window-system path.  It'll be fine.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4037>

---

 src/vulkan/wsi/wsi_common.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index a97e2aa9f7f..c8c9b73a57a 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -33,6 +33,8 @@
 #include "vk_physical_device.h"
 #include "vk_queue.h"
 #include "vk_semaphore.h"
+#include "vk_sync.h"
+#include "vk_sync_dummy.h"
 #include "vk_util.h"
 
 #include <time.h>
@@ -834,15 +836,22 @@ wsi_signal_semaphore_for_image(struct vk_device *device,
                                const struct wsi_image *image,
                                VkSemaphore _semaphore)
 {
-   VK_FROM_HANDLE(vk_semaphore, semaphore, _semaphore);
-
-   if (!chain->wsi->signal_semaphore_with_memory)
+   if (device->physical->supported_sync_types == NULL)
       return VK_SUCCESS;
 
+   VK_FROM_HANDLE(vk_semaphore, semaphore, _semaphore);
+
    vk_semaphore_reset_temporary(device, semaphore);
-   return device->create_sync_for_memory(device, image->memory,
-                                         false /* signal_memory */,
-                                         &semaphore->temporary);
+
+   if (chain->wsi->signal_semaphore_with_memory) {
+      return device->create_sync_for_memory(device, image->memory,
+                                            false /* signal_memory */,
+                                            &semaphore->temporary);
+   } else {
+      return vk_sync_create(device, &vk_sync_dummy_type,
+                            0 /* flags */, 0 /* initial_value */,
+                            &semaphore->temporary);
+   }
 }
 
 static VkResult
@@ -851,15 +860,22 @@ wsi_signal_fence_for_image(struct vk_device *device,
                            const struct wsi_image *image,
                            VkFence _fence)
 {
-   VK_FROM_HANDLE(vk_fence, fence, _fence);
-
-   if (!chain->wsi->signal_fence_with_memory)
+   if (device->physical->supported_sync_types == NULL)
       return VK_SUCCESS;
 
+   VK_FROM_HANDLE(vk_fence, fence, _fence);
+
    vk_fence_reset_temporary(device, fence);
-   return device->create_sync_for_memory(device, image->memory,
-                                         false /* signal_memory */,
-                                         &fence->temporary);
+
+   if (chain->wsi->signal_fence_with_memory) {
+      return device->create_sync_for_memory(device, image->memory,
+                                            false /* signal_memory */,
+                                            &fence->temporary);
+   } else {
+      return vk_sync_create(device, &vk_sync_dummy_type,
+                            0 /* flags */, 0 /* initial_value */,
+                            &fence->temporary);
+   }
 }
 
 VkResult



More information about the mesa-commit mailing list