[PATCH v2 5/5] wined3d: Use a backup device context for swapchains created on the desktop window.

Zebediah Figura zfigura at codeweavers.com
Thu Jun 20 18:56:28 CDT 2019


From: Zebediah Figura <z.figura12 at gmail.com>

This patch was written by "naur".
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18490

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d10core/tests/d3d10core.c | 2 +-
 dlls/d3d11/tests/d3d11.c         | 2 +-
 dlls/d3d8/tests/visual.c         | 7 +------
 dlls/d3d9/tests/visual.c         | 7 +------
 dlls/wined3d/context.c           | 8 +++++++-
 5 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c
index 81442e9bc4..a395467125 100644
--- a/dlls/d3d10core/tests/d3d10core.c
+++ b/dlls/d3d10core/tests/d3d10core.c
@@ -18028,7 +18028,7 @@ static void test_desktop_window(void)
     swapchain_desc.Flags = 0;
 
     hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
-    todo_wine ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
+    ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
             "Failed to create swapchain, hr %#x.\n", hr);
     IDXGIFactory_Release(factory);
     if (FAILED(hr))
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index b8a90ec1ae..1d7a7c7fe7 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -29338,7 +29338,7 @@ static void test_desktop_window(void)
     swapchain_desc.Flags = 0;
 
     hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
-    todo_wine ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
+    ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
             "Failed to create swapchain, hr %#x.\n", hr);
     IDXGIFactory_Release(factory);
     if (FAILED(hr))
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index a35b180a1d..fc7c3cc293 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -11024,12 +11024,7 @@ static void test_desktop_window(void)
     DestroyWindow(window);
 
     device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE);
-    todo_wine ok(!!device, "Failed to create a D3D device.\n");
-    if (!device)
-    {
-        IDirect3D8_Release(d3d);
-        return;
-    }
+    ok(!!device, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index bed74f1e59..5ba07a36dd 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -25813,12 +25813,7 @@ static void test_desktop_window(void)
     DestroyWindow(window);
 
     device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE);
-    todo_wine ok(!!device, "Failed to create a D3D device.\n");
-    if (!device)
-    {
-        IDirect3D9_Release(d3d);
-        return;
-    }
+    ok(!!device, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 5b293b46c0..619b5ff7d0 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1961,10 +1961,16 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
 
     context_gl->tid = GetCurrentThreadId();
     context_gl->window = context->swapchain->win_handle;
-    if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
+    if (context_gl->window == GetDesktopWindow())
     {
+        TRACE("Swapchain is created on the desktop window, trying backup device context.\n");
+        context_gl->dc = NULL;
+    }
+    else if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
         WARN("Failed to retrieve device context, trying swapchain backup.\n");
 
+    if (!context_gl->dc)
+    {
         if (!(context_gl->dc = swapchain_get_backup_dc(context->swapchain)))
         {
             ERR("Failed to retrieve a device context.\n");
-- 
2.20.1




More information about the wine-devel mailing list