From: Philip Rebohle philip.rebohle@tu-dortmund.de
Signed-off-by: Philip Rebohle philip.rebohle@tu-dortmund.de Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- This supersedes patch 183588. %d -> %#x for HRESULTs, which I should have noticed in the original patch.
dlls/dxgi/swapchain.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index f19b58da2e6..0cb7d922f4d 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -1094,6 +1094,9 @@ struct d3d12_swapchain IDXGIOutput *target; DXGI_SWAP_CHAIN_DESC1 desc; DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc; + + ID3D12Fence *frame_latency_fence; + HANDLE frame_latency_event; };
static DXGI_FORMAT dxgi_format_from_vk_format(VkFormat vk_format) @@ -1887,6 +1890,12 @@ static void d3d12_swapchain_destroy(struct d3d12_swapchain *swapchain)
d3d12_swapchain_destroy_buffers(swapchain, TRUE);
+ if (swapchain->frame_latency_event) + CloseHandle(swapchain->frame_latency_event); + + if (swapchain->frame_latency_fence) + ID3D12Fence_Release(swapchain->frame_latency_fence); + if (swapchain->command_queue) ID3D12CommandQueue_Release(swapchain->command_queue);
@@ -2906,7 +2915,7 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IWineDXGI FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling); if (swapchain_desc->AlphaMode && swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE) FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode); - if (swapchain_desc->Flags) + if (swapchain_desc->Flags & ~(DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT)) FIXME("Ignoring swapchain flags %#x.\n", swapchain_desc->Flags);
if (fullscreen_desc->RefreshRate.Numerator || fullscreen_desc->RefreshRate.Denominator) @@ -2983,6 +2992,25 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IWineDXGI return hresult_from_vk_result(vr); }
+ if (swapchain_desc->Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) + { + if (FAILED(hr = ID3D12Device_CreateFence(device, DXGI_MAX_SWAP_CHAIN_BUFFERS, + 0, &IID_ID3D12Fence, (void **)&swapchain->frame_latency_fence))) + { + WARN("Failed to create frame latency fence, hr %#x.\n", hr); + d3d12_swapchain_destroy(swapchain); + return hr; + } + + if (!(swapchain->frame_latency_event = CreateEventW(NULL, FALSE, TRUE, NULL))) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + WARN("Failed to create frame latency event, hr %#x.\n", hr); + d3d12_swapchain_destroy(swapchain); + return hr; + } + } + IWineDXGIFactory_AddRef(swapchain->factory = factory);
return S_OK;