[PATCH 08/10] d3d/tests: Additional swapchains are only allowed in windowed mode.

Stefan Dösinger stefan at codeweavers.com
Thu Sep 25 07:24:24 CDT 2014


Implementing this behavior breaks the dxgi tests at the moment because
wine still creates an implicit swapchain that should not be there and
conflicts with the explicit dxgi swapchains created by the dxgi tests.

An informal test shows that dxgi refuses to create a windowed swapchain
when a fullscreen one exists, but happily creates a fullscreen swapchain
if a windowed one is already there. I do not know if this is a bug or a
feature.

I have moved test_cursor because the test fails for some reason on Wine
if there has been a fullscreen swapchain before it is executed. I have
not yet found out why, but I am sure that the behavior difference is not
in the d3d code.
---
 dlls/d3d8/tests/device.c | 52 +++++++++++++++++++++++++++++++++++++++++++++---
 dlls/d3d9/tests/device.c | 51 +++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 98 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index c715dfd..810d2b4 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -223,12 +223,15 @@ static void test_swapchain(void)
     IDirect3DDevice8 *device;
     IDirect3D8 *d3d;
     ULONG refcount;
-    HWND window;
+    HWND window, window2;
     HRESULT hr;
 
     window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
             0, 0, 640, 480, NULL, NULL, NULL, NULL);
     ok(!!window, "Failed to create a window.\n");
+    window2 = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
+            0, 0, 640, 480, NULL, NULL, NULL, NULL);
+    ok(!!window2, "Failed to create a window.\n");
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
     ok(!!d3d, "Failed to create a D3D object.\n");
     if (!(device = create_device(d3d, window, window, TRUE)))
@@ -317,10 +320,54 @@ static void test_swapchain(void)
     IDirect3DSwapChain8_Release(swapchain3);
     IDirect3DSwapChain8_Release(swapchain2);
     IDirect3DSwapChain8_Release(swapchain1);
+
+    memset(&d3dpp, 0, sizeof(d3dpp));
+    d3dpp.Windowed = FALSE;
+    d3dpp.hDeviceWindow = window;
+    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+    d3dpp.BackBufferWidth = 640;
+    d3dpp.BackBufferHeight = 480;
+    d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+
+    hr = reset_device(device, window, FALSE);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    d3dpp.hDeviceWindow = window;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+    d3dpp.Windowed = TRUE;
+    d3dpp.hDeviceWindow = window;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain8_Release(swapchain1);
+
     refcount = IDirect3DDevice8_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
+    DestroyWindow(window2);
     DestroyWindow(window);
 }
 
@@ -2926,7 +2973,6 @@ static void test_window_style(void)
     ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
             focus_exstyle, style);
 
-
     ref = IDirect3DDevice8_Release(device);
     ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
 
@@ -6579,10 +6625,10 @@ START_TEST(device)
     test_display_formats();
     test_display_modes();
     test_shader_versions();
+    test_cursor();
     test_swapchain();
     test_refcount();
     test_mipmap_levels();
-    test_cursor();
     test_cursor_pos();
     test_states();
     test_reset();
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 6b0bdd2..7177a36 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -1016,12 +1016,15 @@ static void test_swapchain(void)
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
     ULONG refcount;
-    HWND window;
+    HWND window, window2;
     HRESULT hr;
 
     window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
             0, 0, 640, 480, NULL, NULL, NULL, NULL);
     ok(!!window, "Failed to create a window.\n");
+    window2 = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
+            0, 0, 640, 480, NULL, NULL, NULL, NULL);
+    ok(!!window2, "Failed to create a window.\n");
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
     ok(!!d3d, "Failed to create a D3D object.\n");
     if (!(device = create_device(d3d, window, window, TRUE)))
@@ -1134,10 +1137,54 @@ static void test_swapchain(void)
     IDirect3DSwapChain9_Release(swapchain3);
     IDirect3DSwapChain9_Release(swapchain2);
     IDirect3DSwapChain9_Release(swapchain1);
+
+    memset(&d3dpp, 0, sizeof(d3dpp));
+    d3dpp.Windowed = FALSE;
+    d3dpp.hDeviceWindow = window;
+    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+    d3dpp.BackBufferWidth = 640;
+    d3dpp.BackBufferHeight = 480;
+    d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
+    hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+
+    hr = reset_device(device, window, FALSE);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    d3dpp.hDeviceWindow = window;
+    hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+    d3dpp.Windowed = TRUE;
+    d3dpp.hDeviceWindow = window;
+    todo_wine hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+    d3dpp.hDeviceWindow = window2;
+    hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+        IDirect3DSwapChain9_Release(swapchain1);
+
     refcount = IDirect3DDevice9_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
+    DestroyWindow(window2);
     DestroyWindow(window);
 }
 
@@ -9266,11 +9313,11 @@ START_TEST(device)
     test_multi_device();
     test_display_formats();
     test_display_modes();
+    test_cursor();
     test_swapchain();
     test_refcount();
     test_mipmap_levels();
     test_checkdevicemultisampletype();
-    test_cursor();
     test_cursor_pos();
     test_reset_fullscreen();
     test_reset();
-- 
1.8.5.5




More information about the wine-patches mailing list