[PATCH 4/5] d3d9/tests: Use a separate device for sincos_test().

Henri Verbeet hverbeet at codeweavers.com
Tue Mar 25 03:35:43 CDT 2014


---
 dlls/d3d9/tests/visual.c |   49 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index d067517..45539d3 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -11633,8 +11633,18 @@ static void alphatest_test(IDirect3DDevice9 *device) {
     ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with 0x%08x\n", hr);
 }
 
-static void sincos_test(IDirect3DDevice9 *device)
+static void sincos_test(void)
 {
+    IDirect3DVertexShader9 *sin_shader, *cos_shader;
+    IDirect3DDevice9 *device;
+    struct vec3 data[1280];
+    IDirect3D9 *d3d;
+    unsigned int i;
+    ULONG refcount;
+    D3DCAPS9 caps;
+    HWND window;
+    HRESULT hr;
+
     static const DWORD sin_shader_code[] =
     {
         0xfffe0200,                                                                 /* vs_2_0                       */
@@ -11659,14 +11669,27 @@ static void sincos_test(IDirect3DDevice9 *device)
         0x02000001, 0xd00f0000, 0xa0a90002,                                         /* mov oD0, c2.yzzz             */
         0x0000ffff                                                                  /* end                          */
     };
-    IDirect3DVertexShader9 *sin_shader, *cos_shader;
-    HRESULT hr;
-    struct {
-        float x, y, z;
-    } data[1280];
-    unsigned int i;
-    float sincosc1[4] = {D3DSINCOSCONST1};
-    float sincosc2[4] = {D3DSINCOSCONST2};
+    static const float sincosc1[4] = {D3DSINCOSCONST1};
+    static const float sincosc2[4] = {D3DSINCOSCONST2};
+
+    window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, 640, 480, NULL, NULL, NULL, NULL);
+    d3d = Direct3DCreate9(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 = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
+    {
+        skip("No vs_2_0 support, skipping tests.\n");
+        IDirect3DDevice9_Release(device);
+        goto done;
+    }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
     ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
@@ -11708,9 +11731,13 @@ static void sincos_test(IDirect3DDevice9 *device)
     ok(SUCCEEDED(hr), "IDirect3DDevice9_Present returned %#x.\n", hr);
     /* TODO: Find a way to properly validate the lines. Precicion issues make this a kinda nasty task */
 
-    IDirect3DDevice9_SetVertexShader(device, NULL);
     IDirect3DVertexShader9_Release(sin_shader);
     IDirect3DVertexShader9_Release(cos_shader);
+    refcount = IDirect3DDevice9_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+done:
+    IDirect3D9_Release(d3d);
+    DestroyWindow(window);
 }
 
 static void loop_index_test(IDirect3DDevice9 *device)
@@ -16245,13 +16272,13 @@ START_TEST(visual)
     {
         test_mova(device_ptr);
         loop_index_test(device_ptr);
-        sincos_test(device_ptr);
     }
     else skip("No vs_2_0 support\n");
 
     cleanup_device(device_ptr);
     device_ptr = NULL;
 
+    sincos_test();
     sgn_test();
     clip_planes_test();
     test_vshader_input();
-- 
1.7.10.4




More information about the wine-patches mailing list