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: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16629>
This commit is contained in:
Boris Brezillon 2022-05-20 10:31:24 +02:00 committed by Marge Bot
parent 23be0aad9c
commit 1eaba553e2
3 changed files with 8 additions and 5 deletions

View file

@ -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);

View file

@ -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;
};

View file

@ -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),