[PATCH 2/8] dxgi/tests: Add basic test for sync intervals.
Józef Kucia
jkucia at codeweavers.com
Wed Feb 28 05:12:33 CST 2018
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/dxgi/tests/device.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c
index 8351a32e596d..d265978ba4b1 100644
--- a/dlls/dxgi/tests/device.c
+++ b/dlls/dxgi/tests/device.c
@@ -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), "GetAdapter failed, hr %#x.\n", hr);
+ hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
+ ok(SUCCEEDED(hr), "GetParent failed, 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), "CreateSwapChain failed, 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();
--
2.16.1
More information about the wine-devel
mailing list