dxgi/tests: Add basic test for sync intervals.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-03-22 08:48:33 +01:00 committed by Alexandre Julliard
parent 81459fb8a2
commit 3c53b193f7
1 changed files with 58 additions and 0 deletions

View File

@ -3353,6 +3353,63 @@ static void test_swapchain_parameters(void)
DestroyWindow(window);
}
static void test_swapchain_present(void)
{
DXGI_SWAP_CHAIN_DESC swapchain_desc;
IDXGISwapChain *swapchain;
IDXGIAdapter *adapter;
IDXGIFactory *factory;
IDXGIDevice *device;
unsigned int i;
ULONG refcount;
HRESULT hr;
if (!(device = create_device(0)))
{
skip("Failed to create device.\n");
return;
}
hr = IDXGIDevice_GetAdapter(device, &adapter);
ok(SUCCEEDED(hr), "Failed to get adapter, hr %#x.\n", hr);
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to get parent, hr %#x.\n", hr);
IDXGIAdapter_Release(adapter);
swapchain_desc.BufferDesc.Width = 800;
swapchain_desc.BufferDesc.Height = 600;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapchain_desc.SampleDesc.Count = 1;
swapchain_desc.SampleDesc.Quality = 0;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.BufferCount = 1;
swapchain_desc.OutputWindow = CreateWindowA("static", "dxgi_test", 0, 0, 0, 400, 200, 0, 0, 0, 0);
swapchain_desc.Windowed = TRUE;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapchain_desc.Flags = 0;
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
ok(SUCCEEDED(hr), "Failed to create swapchain, hr %#x.\n", hr);
for (i = 0; i < 10; ++i)
{
hr = IDXGISwapChain_Present(swapchain, i, 0);
ok(hr == (i <= 4 ? S_OK : DXGI_ERROR_INVALID_CALL),
"Got unexpected hr %#x for sync interval %u.\n", hr, i);
}
hr = IDXGISwapChain_Present(swapchain, 0, 0);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
IDXGISwapChain_Release(swapchain);
refcount = IDXGIDevice_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
DestroyWindow(swapchain_desc.OutputWindow);
}
static void test_maximum_frame_latency(void)
{
IDXGIDevice1 *device1;
@ -3654,6 +3711,7 @@ START_TEST(device)
test_private_data();
test_swapchain_resize();
test_swapchain_parameters();
test_swapchain_present();
test_maximum_frame_latency();
test_output_desc();
test_object_wrapping();