From 11c943dd7e9a665c86813e67ed8f12ca4f210a25 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 5 Jul 2022 10:58:02 +0200 Subject: [PATCH] vkd3d: Unblock all fence waiters when public ref-count hits 0. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/command.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 3b0f8375..e3bcdc31 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -838,6 +838,17 @@ static ULONG STDMETHODCALLTYPE d3d12_fence_Release(d3d12_fence_iface *iface) if (!refcount) { struct d3d12_device *device = fence->device; + + /* When a fence's public ref-count hits zero, all waiters must be released. + * NOTE: For shared fences later, + * we cannot signal here since we cannot know if there are other fences. + * According to our tests, the fence unblocks all waiters when the last reference + * to the shared HANDLE is released. This is completely outside the scope of what we can + * reasonably implement ourselves. For now, the plan is to wait with timeout + * and mark "TDR" if that ever happens in real world usage. */ + if (!(fence->d3d12_flags & D3D12_FENCE_FLAG_SHARED)) + d3d12_fence_signal_cpu_timeline_semaphore(fence, UINT64_MAX); + d3d12_fence_dec_ref(fence); d3d12_device_release(device); }