dxgi: Implement d3d11_swapchain_GetLastPresentCount().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2021-07-01 16:56:31 +02:00 committed by Alexandre Julliard
parent 7eadbae52c
commit 6f674ef6f1
3 changed files with 23 additions and 12 deletions

View File

@ -182,6 +182,7 @@ struct d3d11_swapchain
IWineDXGIFactory *factory; IWineDXGIFactory *factory;
IDXGIOutput *target; IDXGIOutput *target;
LONG present_count;
}; };
HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device,

View File

@ -328,6 +328,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *ifac
static HRESULT d3d11_swapchain_present(struct d3d11_swapchain *swapchain, static HRESULT d3d11_swapchain_present(struct d3d11_swapchain *swapchain,
unsigned int sync_interval, unsigned int flags) unsigned int sync_interval, unsigned int flags)
{ {
HRESULT hr;
if (sync_interval > 4) if (sync_interval > 4)
{ {
WARN("Invalid sync interval %u.\n", sync_interval); WARN("Invalid sync interval %u.\n", sync_interval);
@ -345,7 +347,9 @@ static HRESULT d3d11_swapchain_present(struct d3d11_swapchain *swapchain,
return S_OK; return S_OK;
} }
return wined3d_swapchain_present(swapchain->wined3d_swapchain, NULL, NULL, NULL, sync_interval, 0); if (SUCCEEDED(hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, NULL, NULL, NULL, sync_interval, 0)))
InterlockedIncrement(&swapchain->present_count);
return hr;
} }
static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_Present(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags) static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_Present(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags)
@ -599,9 +603,13 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFrameStatistics(IDXGISwapCha
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetLastPresentCount(IDXGISwapChain1 *iface, static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetLastPresentCount(IDXGISwapChain1 *iface,
UINT *last_present_count) UINT *last_present_count)
{ {
FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count); struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
return E_NOTIMPL; TRACE("iface %p, last_present_count %p.\n", iface, last_present_count);
*last_present_count = swapchain->present_count;
return S_OK;
} }
/* IDXGISwapChain1 methods */ /* IDXGISwapChain1 methods */

View File

@ -7476,28 +7476,29 @@ static void test_swapchain_present_count(IUnknown *device, BOOL is_d3d12)
present_count = ~0u; present_count = ~0u;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo_wine ok(!present_count, "Got unexpected present count %u.\n", present_count); todo_wine_if(is_d3d12) ok(!present_count, "Got unexpected present count %u.\n", present_count);
hr = IDXGISwapChain_Present(swapchain, 0, 0); hr = IDXGISwapChain_Present(swapchain, 0, 0);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
expected = present_count + 1; expected = present_count + 1;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo_wine ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected); todo_wine_if(is_d3d12)
ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected);
hr = IDXGISwapChain_Present(swapchain, 10, 0); hr = IDXGISwapChain_Present(swapchain, 10, 0);
ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
expected = present_count; expected = present_count;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected); ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected);
hr = IDXGISwapChain_Present(swapchain, 0, DXGI_PRESENT_TEST); hr = IDXGISwapChain_Present(swapchain, 0, DXGI_PRESENT_TEST);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
expected = present_count; expected = present_count;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected); ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected);
ShowWindow(window, SW_MINIMIZE); ShowWindow(window, SW_MINIMIZE);
@ -7505,7 +7506,7 @@ static void test_swapchain_present_count(IUnknown *device, BOOL is_d3d12)
ok(hr == (is_d3d12 ? S_OK : DXGI_STATUS_OCCLUDED), "Got unexpected hr %#x.\n", hr); ok(hr == (is_d3d12 ? S_OK : DXGI_STATUS_OCCLUDED), "Got unexpected hr %#x.\n", hr);
expected = present_count + !!is_d3d12; expected = present_count + !!is_d3d12;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo_wine_if(is_d3d12) todo_wine_if(is_d3d12)
ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected); ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected);
@ -7514,8 +7515,9 @@ static void test_swapchain_present_count(IUnknown *device, BOOL is_d3d12)
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
expected = present_count + 1; expected = present_count + 1;
hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo_wine ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected); todo_wine_if(is_d3d12)
ok(present_count == expected, "Got unexpected present count %u, expected %u.\n", present_count, expected);
IDXGISwapChain_Release(swapchain); IDXGISwapChain_Release(swapchain);
DestroyWindow(window); DestroyWindow(window);