[PATCH 3/6] ddraw/tests: Test rhw table fog z vs rhw.

Stefan Dösinger stefan at codeweavers.com
Thu Feb 12 03:58:44 CST 2015


---
 dlls/ddraw/tests/ddraw7.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index d8706bd..01d0fcb 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -8180,6 +8180,123 @@ static void test_negative_fixedfunction_fog(void)
     DestroyWindow(window);
 }
 
+static void test_table_fog_zw(void)
+{
+    HRESULT hr;
+    IDirect3DDevice7 *device;
+    IDirectDrawSurface7 *rt;
+    ULONG refcount;
+    HWND window;
+    D3DCOLOR color;
+    static struct
+    {
+        struct vec4 position;
+        D3DCOLOR diffuse;
+    }
+    quad[] =
+    {
+        {{  0.0f,   0.0f, 0.0f, 0.0f}, 0xffff0000},
+        {{640.0f,   0.0f, 0.0f, 0.0f}, 0xffff0000},
+        {{  0.0f, 480.0f, 0.0f, 0.0f}, 0xffff0000},
+        {{640.0f, 480.0f, 0.0f, 0.0f}, 0xffff0000},
+    };
+    static D3DMATRIX identity =
+    {
+        1.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 1.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 1.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 1.0f
+    };
+    D3DDEVICEDESC7 caps;
+    static const struct
+    {
+        float z, w;
+        D3DZBUFFERTYPE z_test;
+        D3DCOLOR color;
+    }
+    tests[] =
+    {
+        {0.7f,  0.0f, D3DZB_TRUE,  0x004cb200},
+        {0.7f,  0.0f, D3DZB_FALSE, 0x004cb200},
+        {0.7f,  0.3f, D3DZB_TRUE,  0x004cb200},
+        {0.7f,  0.3f, D3DZB_FALSE, 0x004cb200},
+        {0.7f,  3.0f, D3DZB_TRUE,  0x004cb200},
+        {0.7f,  3.0f, D3DZB_FALSE, 0x004cb200},
+        {0.3f,  0.0f, D3DZB_TRUE,  0x00b24c00},
+        {0.3f,  0.0f, D3DZB_FALSE, 0x00b24c00},
+    };
+    unsigned int i;
+
+    window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+            0, 0, 640, 480, 0, 0, 0, 0);
+
+    if (!(device = create_device(window, DDSCL_NORMAL)))
+    {
+        skip("Failed to create a 3D device, skipping test.\n");
+        DestroyWindow(window);
+        return;
+    }
+
+    hr = IDirect3DDevice7_GetCaps(device, &caps);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE))
+    {
+        skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping POSITIONT table fog test.\n");
+        goto done;
+    }
+    hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0x0000ff00);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    /* Work around an AMD Windows driver bug. Needs a proj matrix applied redundantly. */
+    hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+    for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+    {
+        hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+
+        quad[0].position.z = tests[i].z;
+        quad[1].position.z = tests[i].z;
+        quad[2].position.z = tests[i].z;
+        quad[3].position.z = tests[i].z;
+        quad[0].position.w = tests[i].w;
+        quad[1].position.w = tests[i].w;
+        quad[2].position.w = tests[i].w;
+        quad[3].position.w = tests[i].w;
+        hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, tests[i].z_test);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+        hr = IDirect3DDevice7_BeginScene(device);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad, 4, 0);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        hr = IDirect3DDevice7_EndScene(device);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+
+        color = get_surface_color(rt, 0, 240);
+        ok(compare_color(color, tests[i].color, 2),
+                "Got unexpected color 0x%08x, expected 0x%8x, case %u.\n", color, tests[i].color, i);
+    }
+
+    IDirectDrawSurface7_Release(rt);
+done:
+    refcount = IDirect3DDevice7_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+    DestroyWindow(window);
+}
+
 START_TEST(ddraw7)
 {
     HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -8268,4 +8385,5 @@ START_TEST(ddraw7)
     test_surface_desc_lock();
     test_fog_interpolation();
     test_negative_fixedfunction_fog();
+    test_table_fog_zw();
 }
-- 
2.0.5




More information about the wine-patches mailing list