Henri Verbeet : d3d8/tests: Use a separate device for volume_dxt5_test().

Alexandre Julliard julliard at winehq.org
Wed Apr 16 12:11:38 CDT 2014


Module: wine
Branch: master
Commit: d93cbeca511856aad65675f24ad5ee9f079160f0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d93cbeca511856aad65675f24ad5ee9f079160f0

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Apr 16 08:55:21 2014 +0200

d3d8/tests: Use a separate device for volume_dxt5_test().

---

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

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index ce4de4a..e3e33e2 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -4046,14 +4046,18 @@ static void fog_special_test(IDirect3DDevice8 *device)
         IDirect3DDevice8_DeletePixelShader(device, ps);
 }
 
-static void volume_dxt5_test(IDirect3DDevice8 *device)
+static void volume_dxt5_test(void)
 {
-    HRESULT hr;
-    IDirect3D8 *d3d8;
     IDirect3DVolumeTexture8 *texture;
+    IDirect3DDevice8 *device;
     D3DLOCKED_BOX box;
+    IDirect3D8 *d3d;
     unsigned int i;
-    DWORD color;
+    D3DCOLOR color;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
     static const char texture_data[] =
     {
         /* A 8x4x2 texture consisting of 4 4x4 blocks. The colors of the blocks are red, green, blue and white. */
@@ -4070,26 +4074,33 @@ static void volume_dxt5_test(IDirect3DDevice8 *device)
     quads[] =
     {
         {{ -1.0f,  -1.0f,  0.0f}, { 0.0f, 0.0f, 0.25f}},
-        {{  0.0f,  -1.0f,  1.0f}, { 1.0f, 0.0f, 0.25f}},
         {{ -1.0f,   1.0f,  0.0f}, { 0.0f, 1.0f, 0.25f}},
+        {{  0.0f,  -1.0f,  1.0f}, { 1.0f, 0.0f, 0.25f}},
         {{  0.0f,   1.0f,  1.0f}, { 1.0f, 1.0f, 0.25f}},
 
         {{  0.0f,  -1.0f,  0.0f}, { 0.0f, 0.0f, 0.75f}},
-        {{  1.0f,  -1.0f,  1.0f}, { 1.0f, 0.0f, 0.75f}},
         {{  0.0f,   1.0f,  0.0f}, { 0.0f, 1.0f, 0.75f}},
+        {{  1.0f,  -1.0f,  1.0f}, { 1.0f, 0.0f, 0.75f}},
         {{  1.0f,   1.0f,  1.0f}, { 1.0f, 1.0f, 0.75f}},
     };
     static const DWORD expected_colors[] = {0x00ff0000, 0x0000ff00, 0x000000ff, 0x00ffffff};
 
-    hr = IDirect3DDevice8_GetDirect3D(device, &d3d8);
-    ok(SUCCEEDED(hr), "Failed to get d3d8 interface, hr %#x.\n", hr);
-    hr = IDirect3D8_CheckDeviceFormat(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
-            D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT5);
-    IDirect3D8_Release(d3d8);
-    if (FAILED(hr))
+    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("Volume dxt5 textures are not supported, skipping test.\n");
-        return;
+        skip("Failed to create a D3D device, skipping tests.\n");
+        goto done;
+    }
+
+    if (FAILED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+            D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT5)))
+    {
+        skip("Volume DXT5 textures are not supported, skipping test.\n");
+        IDirect3DDevice8_Release(device);
+        goto done;
     }
 
     hr = IDirect3DDevice8_CreateVolumeTexture(device, 8, 4, 2, 1, 0, D3DFMT_DXT5,
@@ -4115,7 +4126,7 @@ static void volume_dxt5_test(IDirect3DDevice8 *device)
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
     ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#x.\n", hr);
 
-    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0);
+    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
     hr = IDirect3DDevice8_BeginScene(device);
     ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
@@ -4135,11 +4146,12 @@ static void volume_dxt5_test(IDirect3DDevice8 *device)
                 "Expected color 0x%08x, got 0x%08x, case %u.\n", expected_colors[i], color, i);
     }
 
-    hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
-    hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
     IDirect3DVolumeTexture8_Release(texture);
+    refcount = IDirect3DDevice8_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+done:
+    IDirect3D8_Release(d3d);
+    DestroyWindow(window);
 }
 
 static void volume_v16u16_test(void)
@@ -4748,7 +4760,6 @@ START_TEST(visual)
     zenable_test(device_ptr);
     resz_test(device_ptr);
     fog_special_test(device_ptr);
-    volume_dxt5_test(device_ptr);
 
     refcount = IDirect3DDevice8_Release(device_ptr);
     ok(!refcount, "Device has %u references left.\n", refcount);
@@ -4756,6 +4767,7 @@ cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 
+    volume_dxt5_test();
     volume_v16u16_test();
     add_dirty_rect_test();
 }




More information about the wine-cvs mailing list