From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/dxgi/swapchain.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 78cd2697b75..b1438eb97b7 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -1248,6 +1248,7 @@ static void d3d12_swapchain_op_destroy(struct d3d12_swapchain *swapchain, struct
static HRESULT d3d12_swapchain_op_present_execute(struct d3d12_swapchain *swapchain, struct d3d12_swapchain_op *op); static HRESULT d3d12_swapchain_op_resize_buffers_execute(struct d3d12_swapchain *swapchain, struct d3d12_swapchain_op *op); +static VkResult d3d12_swapchain_acquire_next_vulkan_image(struct d3d12_swapchain *swapchain);
static DWORD WINAPI d3d12_swapchain_worker_proc(void *data) { @@ -1269,6 +1270,17 @@ static DWORD WINAPI d3d12_swapchain_worker_proc(void *data)
list_remove(&op->entry);
+ if (op->type == D3D12_SWAPCHAIN_OP_PRESENT && swapchain->vk_image_index == INVALID_VK_IMAGE_INDEX) + { + /* vkAcquireNextImageKHR() will block if an image is not available. Let it block inside + * the critical section to delay a new present op being queued, otherwise the client will + * continue rendering and overwrite a pending image. Doing this at least approximates + * D3D12 frame latency behaviour if the frame latency equals the buffer count. + * TODO: implement frame latency when it differs from the buffer count. + * Do not bother handling failure here, as vk_image_index remains invalid in that case. */ + d3d12_swapchain_acquire_next_vulkan_image(swapchain); + } + LeaveCriticalSection(&swapchain->worker_cs);
switch (op->type)