diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-10-18 21:51:05 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-11-11 18:49:31 +0300 |
commit | 19df064875ecf22ca7cdaa6b1ba95fddef877789 (patch) | |
tree | 64c0d00aca0424f261cf41d83e6a2fc5717f2162 | |
parent | 89c8e522cf8663d98521bed8e305f9afade3e959 (diff) |
vkd3d: Ensure all fence signals have completed.
Before calling CloseHandle, need to ensure all pending signals completed
so that the fence waiter threads don't accidentally Release a closed or recycled handle.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r-- | libs/vkd3d/swapchain_new.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/vkd3d/swapchain_new.c b/libs/vkd3d/swapchain_new.c index 595308fc..6b588749 100644 --- a/libs/vkd3d/swapchain_new.c +++ b/libs/vkd3d/swapchain_new.c @@ -171,6 +171,18 @@ static void dxgi_vk_swap_chain_drain_queue(struct dxgi_vk_swap_chain *chain) } else ERR("Failed to acquire queue.\n"); + + /* Ensures that all pending ReleaseSemaphore() calls are also made. + * This happens on the fence waiter queues, so it's not enough to call vkQueueWaitIdle to be 100% sure. + * The fence waiter thread processes requests in-order, + * so if we observe that an EVENT has been signalled, + * we know all pending semaphore signals have happened as well. */ + + /* This is safe since we have drained all outstanding CPU work on the queue after calling vkd3d_acquire_vk_queue(). */ + chain->present.frame_latency_count += 1; + d3d12_command_queue_signal_inline(chain->queue, chain->present.frame_latency_fence, chain->present.frame_latency_count); + d3d12_fence_set_event_on_completion(impl_from_ID3D12Fence1(chain->present.frame_latency_fence), + chain->present.frame_latency_count, NULL, VKD3D_WAITING_EVENT_TYPE_EVENT); } static void dxgi_vk_swap_chain_drain_user_images(struct dxgi_vk_swap_chain *chain) |