From 568e08e27ea1d281d21c2721c1188f7b140fcc63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B3zef=20Kucia?= Date: Sun, 18 Sep 2016 16:18:17 +0200 Subject: [PATCH] d3d10core/tests: Port test_swapchain_formats() from d3d11. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d10core/tests/device.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 98a25ff2fd9..37b08e5e070 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -7275,6 +7275,73 @@ float4 main(const ps_in v) : SV_TARGET release_test_context(&test_context); } +static void test_swapchain_formats(void) +{ + DXGI_SWAP_CHAIN_DESC swapchain_desc; + IDXGISwapChain *swapchain; + IDXGIDevice *dxgi_device; + IDXGIAdapter *adapter; + IDXGIFactory *factory; + ID3D10Device *device; + unsigned int i; + ULONG refcount; + HRESULT hr; + + if (!(device = create_device())) + { + skip("Failed to create device.\n"); + return; + } + + swapchain_desc.BufferDesc.Width = 800; + swapchain_desc.BufferDesc.Height = 600; + swapchain_desc.BufferDesc.RefreshRate.Numerator = 0; + swapchain_desc.BufferDesc.RefreshRate.Denominator = 0; + 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", "d3d10core_test", 0, 0, 0, 0, 0, 0, 0, 0, 0); + swapchain_desc.Windowed = TRUE; + swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + swapchain_desc.Flags = 0; + + hr = ID3D10Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); + ok(SUCCEEDED(hr), "Failed to query IDXGIDevice, hr %#x.\n", hr); + hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter); + ok(SUCCEEDED(hr), "GetAdapter failed, hr %#x.\n", hr); + IDXGIDevice_Release(dxgi_device); + hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); + ok(SUCCEEDED(hr), "GetParent failed, hr %#x.\n", hr); + IDXGIAdapter_Release(adapter); + + swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; + hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain); + todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x for typeless format.\n", hr); + if (SUCCEEDED(hr)) + IDXGISwapChain_Release(swapchain); + + for (i = 0; i < sizeof(display_format_support) / sizeof(*display_format_support); ++i) + { + if (display_format_support[i].optional) + continue; + + swapchain_desc.BufferDesc.Format = display_format_support[i].format; + hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain); + ok(hr == S_OK, "Got unexpected hr %#x for format %#x.\n", hr, display_format_support[i].format); + refcount = IDXGISwapChain_Release(swapchain); + ok(!refcount, "Swapchain has %u references left.\n", refcount); + } + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDXGIFactory_Release(factory); + ok(!refcount, "Factory has %u references left.\n", refcount); + DestroyWindow(swapchain_desc.OutputWindow); +} + static void test_swapchain_views(void) { struct d3d10core_test_context test_context; @@ -9494,6 +9561,7 @@ START_TEST(device) test_texture_data_init(); test_check_multisample_quality_levels(); test_cb_relative_addressing(); + test_swapchain_formats(); test_swapchain_views(); test_swapchain_flip(); test_clear_render_target_view(); -- 2.11.4.GIT