Mesa (main): lavapipe: Go back to manually signaling in lvp_AcquireNextImage2()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 6 18:59:36 UTC 2022


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

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Wed Apr  6 10:50:10 2022 -0500

lavapipe: Go back to manually signaling in lvp_AcquireNextImage2()

When porting lavapipe to the common sync framework, I stole the dummy
sync signal_for_memory idea from RADV but didn't actually do it
correctly.  Unless you set wsi_device::signal_semaphore_with_memory and
wsi_device::signal_fence_with_memory, it doesn't actually signal
anything.  If you do set those, it works but also results in dummy
syncs being created for present fences which we see as signals.  We
could choose to just skip those like RADV does but that's too magic.
Instead, have our own AcquireNextImage2() again which sets dummy syncs.

Fixes: 3b547a9b5816 ("lavapipe: Switch to the common sync framework")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15774>

---

 src/gallium/frontends/lavapipe/lvp_device.c | 11 --------
 src/gallium/frontends/lavapipe/lvp_wsi.c    | 43 +++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c
index f6464819444..fda0eed7053 100644
--- a/src/gallium/frontends/lavapipe/lvp_device.c
+++ b/src/gallium/frontends/lavapipe/lvp_device.c
@@ -26,7 +26,6 @@
 #include "pipe-loader/pipe_loader.h"
 #include "git_sha1.h"
 #include "vk_cmd_enqueue_entrypoints.h"
-#include "vk_sync_dummy.h"
 #include "vk_util.h"
 #include "pipe/p_config.h"
 #include "pipe/p_defines.h"
@@ -1463,15 +1462,6 @@ unref_pipeline_layout(struct vk_device *vk_device, VkPipelineLayout _layout)
    lvp_pipeline_layout_unref(device, layout);
 }
 
-static VkResult
-lvp_create_sync_for_memory(struct vk_device *device,
-                           VkDeviceMemory memory,
-                           bool signal_memory,
-                           struct vk_sync **sync_out)
-{
-   return vk_sync_create(device, &vk_sync_dummy_type, 0, 1, sync_out);
-}
-
 VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
    VkPhysicalDevice                            physicalDevice,
    const VkDeviceCreateInfo*                   pCreateInfo,
@@ -1516,7 +1506,6 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
    device->instance = (struct lvp_instance *)physical_device->vk.instance;
    device->physical_device = physical_device;
 
-   device->vk.create_sync_for_memory = lvp_create_sync_for_memory;
    device->vk.ref_pipeline_layout = ref_pipeline_layout;
    device->vk.unref_pipeline_layout = unref_pipeline_layout;
 
diff --git a/src/gallium/frontends/lavapipe/lvp_wsi.c b/src/gallium/frontends/lavapipe/lvp_wsi.c
index 39d4f826fa8..333241ac97a 100644
--- a/src/gallium/frontends/lavapipe/lvp_wsi.c
+++ b/src/gallium/frontends/lavapipe/lvp_wsi.c
@@ -23,6 +23,10 @@
 
 #include "lvp_wsi.h"
 
+#include "vk_fence.h"
+#include "vk_semaphore.h"
+#include "vk_sync_dummy.h"
+
 static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
 lvp_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
 {
@@ -55,3 +59,42 @@ lvp_finish_wsi(struct lvp_physical_device *physical_device)
    wsi_device_finish(&physical_device->wsi_device,
                      &physical_device->vk.instance->alloc);
 }
+
+VKAPI_ATTR VkResult VKAPI_CALL lvp_AcquireNextImage2KHR(
+   VkDevice                                     _device,
+   const VkAcquireNextImageInfoKHR*             pAcquireInfo,
+   uint32_t*                                    pImageIndex)
+{
+   LVP_FROM_HANDLE(lvp_device, device, _device);
+   struct lvp_physical_device *pdevice = device->physical_device;
+
+   VkResult result = wsi_common_acquire_next_image2(&pdevice->wsi_device,
+                                                    _device,
+                                                    pAcquireInfo,
+                                                    pImageIndex);
+
+   VK_FROM_HANDLE(vk_fence, fence, pAcquireInfo->fence);
+   VK_FROM_HANDLE(vk_semaphore, sem, pAcquireInfo->semaphore);
+   if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) {
+      VkResult sync_res;
+      if (fence) {
+         vk_fence_reset_temporary(&device->vk, fence);
+         sync_res = vk_sync_create(&device->vk, &vk_sync_dummy_type,
+                                   0 /* flags */, 0 /* initial_value */,
+                                   &fence->temporary);
+         if (sync_res != VK_SUCCESS)
+            return sync_res;
+      }
+
+      if (sem) {
+         vk_semaphore_reset_temporary(&device->vk, sem);
+         sync_res = vk_sync_create(&device->vk, &vk_sync_dummy_type,
+                                   0 /* flags */, 0 /* initial_value */,
+                                   &sem->temporary);
+         if (sync_res != VK_SUCCESS)
+            return sync_res;
+      }
+   }
+
+   return result;
+}



More information about the mesa-commit mailing list