Mesa (main): dzn: Use the vk_sync_binary abstraction

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 23 08:15:50 UTC 2022


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

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>

---

 src/microsoft/vulkan/dzn_device.c  | 3 +++
 src/microsoft/vulkan/dzn_private.h | 5 ++++-
 src/microsoft/vulkan/dzn_sync.c    | 5 +----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c
index 989919aab3e..2c34f35fd78 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -193,6 +193,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;
 }
@@ -266,6 +268,7 @@ dzn_physical_device_create(struct 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 faf99825385..48bae7a38af 100644
--- a/src/microsoft/vulkan/dzn_private.h
+++ b/src/microsoft/vulkan/dzn_private.h
@@ -34,6 +34,7 @@
 #include "vk_physical_device.h"
 #include "vk_render_pass.h"
 #include "vk_sync.h"
+#include "vk_sync_binary.h"
 #include "vk_queue.h"
 #include "vk_shader_module.h"
 #include "wsi_common.h"
@@ -158,7 +159,7 @@ const struct dzn_meta_blit *
 dzn_meta_blits_get_context(struct dzn_device *device,
                            const struct dzn_meta_blit_key *key);
 
-#define MAX_SYNC_TYPES 2
+#define MAX_SYNC_TYPES 3
 #define MAX_QUEUE_FAMILIES 3
 
 struct dzn_physical_device {
@@ -931,6 +932,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.c b/src/microsoft/vulkan/dzn_sync.c
index 1379c332c4e..9b1312b9712 100644
--- a/src/microsoft/vulkan/dzn_sync.c
+++ b/src/microsoft/vulkan/dzn_sync.c
@@ -190,12 +190,9 @@ dzn_sync_wait(struct vk_device *device,
 const struct vk_sync_type dzn_sync_type = {
    .size = sizeof(struct 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