[PATCH 2/2] d3d9/tests: Demonstrate that NULL HWNDs don't prevent device creation

Andrew Eikum aeikum at codeweavers.com
Wed Jun 1 13:05:25 CDT 2022


The game Planetary Annihilation: TITANS depends on this.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
 dlls/d3d9/tests/d3d9ex.c | 22 ++++++++++++++++++++++
 dlls/d3d9/tests/visual.c | 22 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index fc148aca4a8..86ac7cf5109 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -4925,12 +4925,24 @@ static void test_pinned_buffers(void)
 
 static void test_desktop_window(void)
 {
+    IDirect3DVertexShader9 *shader;
     IDirect3DDevice9Ex *device;
     D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
 
+    static const DWORD simple_vs[] =
+    {
+        0xfffe0101,                                     /* vs_1_1             */
+        0x0000001f, 0x80000000, 0x900f0000,             /* dcl_position0 v0   */
+        0x00000009, 0xc0010000, 0x90e40000, 0xa0e40000, /* dp4 oPos.x, v0, c0 */
+        0x00000009, 0xc0020000, 0x90e40000, 0xa0e40001, /* dp4 oPos.y, v0, c1 */
+        0x00000009, 0xc0040000, 0x90e40000, 0xa0e40002, /* dp4 oPos.z, v0, c2 */
+        0x00000009, 0xc0080000, 0x90e40000, 0xa0e40003, /* dp4 oPos.w, v0, c3 */
+        0x0000ffff,                                     /* end                */
+    };
+
     window = create_window();
     if (!(device = create_device(window, NULL)))
     {
@@ -4954,6 +4966,16 @@ static void test_desktop_window(void)
 
     refcount = IDirect3DDevice9Ex_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
+
+    /* test device with NULL HWND */
+    device = create_device(NULL, NULL);
+    ok(!!device, "Failed to create a D3D device\n");
+
+    hr = IDirect3DDevice9Ex_CreateVertexShader(device, simple_vs, &shader);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    IDirect3DVertexShader9_Release(shader);
+
+    IDirect3DDevice9Ex_Release(device);
 }
 
 START_TEST(d3d9ex)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 2913583916a..bd394d071af 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26122,6 +26122,7 @@ static void test_nrm_instruction(void)
 
 static void test_desktop_window(void)
 {
+    IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
     D3DCOLOR color;
@@ -26129,6 +26130,17 @@ static void test_desktop_window(void)
     HWND window;
     HRESULT hr;
 
+    static const DWORD simple_vs[] =
+    {
+        0xfffe0101,                                     /* vs_1_1                       */
+        0x0000001f, 0x80000000, 0x900f0000,             /* dcl_position0 v0             */
+        0x00000009, 0xc0010000, 0x90e40000, 0xa0e40000, /* dp4 oPos.x, v0, c0           */
+        0x00000009, 0xc0020000, 0x90e40000, 0xa0e40001, /* dp4 oPos.y, v0, c1           */
+        0x00000009, 0xc0040000, 0x90e40000, 0xa0e40002, /* dp4 oPos.z, v0, c2           */
+        0x00000009, 0xc0080000, 0x90e40000, 0xa0e40003, /* dp4 oPos.w, v0, c3           */
+        0x0000ffff,                                     /* end                          */
+    };
+
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
     ok(!!d3d, "Failed to create a D3D object.\n");
@@ -26156,6 +26168,16 @@ static void test_desktop_window(void)
     refcount = IDirect3DDevice9_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
 
+    /* test device with NULL HWND */
+    device = create_device(d3d, NULL, NULL, TRUE);
+    ok(device != NULL, "Failed to create a D3D device\n");
+
+    hr = IDirect3DDevice9_CreateVertexShader(device, simple_vs, &shader);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    IDirect3DVertexShader9_Release(shader);
+
+    IDirect3DDevice9_Release(device);
+
     IDirect3D9_Release(d3d);
 }
 
-- 
2.36.1




More information about the wine-devel mailing list