[PATCH] d3d9/tests: Demonstrate that NULL HWNDs don't prevent device creation
Andrew Eikum
aeikum at codeweavers.com
Thu May 19 10:32:35 CDT 2022
The game Planetary Annihilation: TITANS depends on this.
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
The game does not actually try to Present (though it does create some
shaders). I was just curious if it would fail. We can drop that test if
it is uninteresting.
Note that earlier in the function, we will exit early if create_device
fails (e.g. due to missing hardware or something), so it's OK to require
it to succeed here.
dlls/d3d9/tests/d3d9ex.c | 25 +++++++++++++++++++++++++
dlls/d3d9/tests/device.c | 15 +++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 2afe73088c7..fd34b7ed2f8 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -3473,6 +3473,7 @@ static void test_window_style(void)
LONG device_style, device_exstyle, expected_style;
LONG focus_style, focus_exstyle;
struct device_desc device_desc;
+ IDirect3DVertexShader9 *shader;
LONG style;
IDirect3DDevice9Ex *device;
HRESULT hr;
@@ -3494,6 +3495,17 @@ static void test_window_style(void)
};
unsigned int i;
+ 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 */
+ };
+
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
@@ -3662,6 +3674,19 @@ static void test_window_style(void)
DestroyWindow(device_window);
DestroyWindow(focus_window);
}
+
+ /* 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);
+
+ hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ IDirect3DDevice9Ex_Release(device);
}
static void test_swapchain_parameters(void)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 7abf9ea3df2..53f8a28c910 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -5012,6 +5012,7 @@ static void test_window_style(void)
LONG device_style, device_exstyle;
LONG focus_style, focus_exstyle;
struct device_desc device_desc;
+ IDirect3DVertexShader9 *shader;
LONG style, expected_style;
IDirect3DDevice9 *device;
IDirect3D9 *d3d9;
@@ -5156,6 +5157,20 @@ static void test_window_style(void)
DestroyWindow(device_window);
DestroyWindow(focus_window);
}
+
+ /* test device with NULL HWND */
+ device = create_device(d3d9, NULL, NULL);
+ ok(device != NULL, "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);
+
+ hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ IDirect3DDevice9_Release(device);
+
IDirect3D9_Release(d3d9);
}
--
2.36.1
More information about the wine-devel
mailing list