Mesa (staging/22.1): dzn: Use the vk_sync_binary abstraction

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 23 18:09:44 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 9f02c76abc9bdf4c4e6241ee93e9b869704d0cc9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f02c76abc9bdf4c4e6241ee93e9b869704d0cc9

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Fri May 20 10:31:24 2022 +0200

dzn: Use the vk_sync_binary abstraction

D3D12 fences are capable of handling binary operations, but the
current dzn_sync implementation doesn't match vk_sync expectations
when sync objects are used to back semaphores. In that case, the wait
operation is supposed to set the sync object back to an unsignaled
state after the wait succeeded, but there's no way of knowing what
the sync object is used for, and this implicit-reset behavior is not
expected on fence objects, which also use the sync primitive.
That means we currently have a semaphore implementation that works
only once, and, as soon as the semaphore object has been signaled it
stays in a signaled state until it's destroyed.

We could extend the sync framework to pass an
implicit-reset-after-wait flag, but, given no one else seems to
need that, it's probably simpler to drop the binary sync
capability and rely on the binary-on-top-of-timeline emulation provided
by the core.

Fixes: a012b219640e ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16629>
(cherry picked from commit 1eaba553e24c5569c0f47a6fdd22a545e8e78ffa)

---

 .pick_status.json                   | 2 +-
 src/microsoft/vulkan/dzn_device.cpp | 3 +++
 src/microsoft/vulkan/dzn_private.h  | 5 ++++-
 src/microsoft/vulkan/dzn_sync.cpp   | 5 +----
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 7dd352a2d22..8976a19113e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -139,7 +139,7 @@
         "description": "dzn: Use the vk_sync_binary abstraction",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "a012b219640e875aa552b37dfdaf69336d5863c7"
     },
diff --git a/src/microsoft/vulkan/dzn_device.cpp b/src/microsoft/vulkan/dzn_device.cpp
index 3312a06aeee..27d88ef532b 100644
--- a/src/microsoft/vulkan/dzn_device.cpp
+++ b/src/microsoft/vulkan/dzn_device.cpp
@@ -185,6 +185,8 @@ dzn_instance_create(const VkInstanceCreateInfo *pCreateInfo,
    if (instance->debug_flags & DZN_DEBUG_GBV)
       d3d12_enable_gpu_validation();
 
+   instance->sync_binary_type = vk_sync_binary_get_type(&dzn_sync_type);
+
    *out = dzn_instance_to_handle(instance);
    return VK_SUCCESS;
 }
@@ -258,6 +260,7 @@ dzn_physical_device_create(dzn_instance *instance,
 
    uint32_t num_sync_types = 0;
    pdev->sync_types[num_sync_types++] = &dzn_sync_type;
+   pdev->sync_types[num_sync_types++] = &instance->sync_binary_type.sync;
    pdev->sync_types[num_sync_types++] = &vk_sync_dummy_type;
    pdev->sync_types[num_sync_types] = NULL;
    assert(num_sync_types <= MAX_SYNC_TYPES);
diff --git a/src/microsoft/vulkan/dzn_private.h b/src/microsoft/vulkan/dzn_private.h
index d6145dfaa0c..0bbc0f7defe 100644
--- a/src/microsoft/vulkan/dzn_private.h
+++ b/src/microsoft/vulkan/dzn_private.h
@@ -33,6 +33,7 @@
 #include "vk_log.h"
 #include "vk_physical_device.h"
 #include "vk_sync.h"
+#include "vk_sync_binary.h"
 #include "vk_queue.h"
 #include "vk_shader_module.h"
 #include "wsi_common.h"
@@ -159,7 +160,7 @@ struct dzn_meta_blits {
 const dzn_meta_blit *
 dzn_meta_blits_get_context(dzn_device *device, const dzn_meta_blit_key *key);
 
-#define MAX_SYNC_TYPES 2
+#define MAX_SYNC_TYPES 3
 #define MAX_QUEUE_FAMILIES 3
 
 struct dzn_physical_device {
@@ -947,6 +948,8 @@ struct dzn_instance {
    bool physical_devices_enumerated;
    uint32_t debug_flags;
 
+   struct vk_sync_binary_type sync_binary_type;
+
    struct list_head physical_devices;
 };
 
diff --git a/src/microsoft/vulkan/dzn_sync.cpp b/src/microsoft/vulkan/dzn_sync.cpp
index 583543f72d7..85159d58dde 100644
--- a/src/microsoft/vulkan/dzn_sync.cpp
+++ b/src/microsoft/vulkan/dzn_sync.cpp
@@ -183,12 +183,9 @@ dzn_sync_wait(struct vk_device *device,
 const struct vk_sync_type dzn_sync_type = {
    .size = sizeof(dzn_sync),
    .features = (enum vk_sync_features)
-      (VK_SYNC_FEATURE_BINARY |
-       VK_SYNC_FEATURE_TIMELINE |
+      (VK_SYNC_FEATURE_TIMELINE |
        VK_SYNC_FEATURE_GPU_WAIT |
-       VK_SYNC_FEATURE_GPU_MULTI_WAIT |
        VK_SYNC_FEATURE_CPU_WAIT |
-       VK_SYNC_FEATURE_CPU_RESET |
        VK_SYNC_FEATURE_CPU_SIGNAL |
        VK_SYNC_FEATURE_WAIT_ANY |
        VK_SYNC_FEATURE_WAIT_BEFORE_SIGNAL),



More information about the mesa-commit mailing list