[PATCH 2/5] d3d8/tests: Use a separate device for z_range_test().

Henri Verbeet hverbeet at codeweavers.com
Mon Apr 21 01:10:33 CDT 2014


---
 dlls/d3d8/tests/visual.c |   52 ++++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 6ee64cf..61acad2 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -1491,8 +1491,17 @@ done:
     DestroyWindow(window);
 }
 
-static void z_range_test(IDirect3DDevice8 *device)
+static void z_range_test(void)
 {
+    IDirect3DDevice8 *device;
+    IDirect3D8 *d3d;
+    D3DCOLOR color;
+    ULONG refcount;
+    D3DCAPS8 caps;
+    DWORD shader;
+    HWND window;
+    HRESULT hr;
+
     static const struct vertex quad[] =
     {
         {-1.0f, 0.0f,  1.1f, 0xffff0000},
@@ -1509,22 +1518,18 @@ static void z_range_test(IDirect3DDevice8 *device)
     };
     static const struct tvertex quad3[] =
     {
-        {  0.0f, 240.0f,  1.1f, 1.0f, 0xffffff00},
-        {  0.0f, 480.0f,  1.1f, 1.0f, 0xffffff00},
         {640.0f, 240.0f, -1.1f, 1.0f, 0xffffff00},
         {640.0f, 480.0f, -1.1f, 1.0f, 0xffffff00},
+        {  0.0f, 240.0f,  1.1f, 1.0f, 0xffffff00},
+        {  0.0f, 480.0f,  1.1f, 1.0f, 0xffffff00},
     };
     static const struct tvertex quad4[] =
     {
-        {  0.0f, 240.0f,  1.1f, 1.0f, 0xff00ff00},
-        {  0.0f, 480.0f,  1.1f, 1.0f, 0xff00ff00},
         {640.0f, 240.0f, -1.1f, 1.0f, 0xff00ff00},
         {640.0f, 480.0f, -1.1f, 1.0f, 0xff00ff00},
+        {  0.0f, 240.0f,  1.1f, 1.0f, 0xff00ff00},
+        {  0.0f, 480.0f,  1.1f, 1.0f, 0xff00ff00},
     };
-    HRESULT hr;
-    DWORD color;
-    DWORD shader;
-    D3DCAPS8 caps;
     static const DWORD shader_code[] =
     {
         0xfffe0101,                                     /* vs_1_1           */
@@ -1541,6 +1546,16 @@ static void z_range_test(IDirect3DDevice8 *device)
         D3DVSD_END()
     };
 
+    window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, 640, 480, NULL, NULL, NULL, NULL);
+    d3d = Direct3DCreate8(D3D_SDK_VERSION);
+    ok(!!d3d, "Failed to create a D3D object.\n");
+    if (!(device = create_device(d3d, window, window, TRUE)))
+    {
+        skip("Failed to create a D3D device, skipping tests.\n");
+        goto done;
+    }
+
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
     ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
 
@@ -1555,6 +1570,8 @@ static void z_range_test(IDirect3DDevice8 *device)
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
 
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+    ok(SUCCEEDED(hr), "Failed to disabled lighting, hr %#x.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, TRUE);
     ok(SUCCEEDED(hr), "Failed to enable clipping, hr %#x.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
@@ -1644,7 +1661,8 @@ static void z_range_test(IDirect3DDevice8 *device)
     if (caps.VertexShaderVersion < D3DVS_VERSION(1, 1))
     {
         skip("Vertex shaders not supported\n");
-        goto out;
+        IDirect3DDevice8_Release(device);
+        goto done;
     }
     hr = IDirect3DDevice8_CreateVertexShader(device, vertex_declaration, shader_code, &shader, 0);
     ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
@@ -1703,13 +1721,11 @@ static void z_range_test(IDirect3DDevice8 *device)
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
 
-out:
-    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
-    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
-    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable z writes, hr %#x.\n", hr);
+    refcount = IDirect3DDevice8_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+done:
+    IDirect3D8_Release(d3d);
+    DestroyWindow(window);
 }
 
 static void test_scalar_instructions(void)
@@ -4946,7 +4962,6 @@ START_TEST(visual)
     lighting_test(device_ptr);
     clear_test(device_ptr);
     fog_test(device_ptr);
-    z_range_test(device_ptr);
 
     refcount = IDirect3DDevice8_Release(device_ptr);
     ok(!refcount, "Device has %u references left.\n", refcount);
@@ -4954,6 +4969,7 @@ cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 
+    z_range_test();
     offscreen_test();
     alpha_test();
     test_scalar_instructions();
-- 
1.7.10.4




More information about the wine-patches mailing list