[PATCH 3/4] d3d/tests: Table fog does not abs the fog coordinate (v2).

Stefan Dösinger stefan at codeweavers.com
Thu Nov 27 05:12:35 CST 2014


Version 2: Fix test failures on the testbot. We have to run the
depth-clamped XYZRHW tests first, otherwise depth clamping is broken on
this driver.

Testing this with non-transformed vertices is pointless because z < 0.0
would be clipped anyway in the ortho_fog case. Otherwise we should use
gl_Position.w (but currently don't), which can't be < 0.0 either.
---
 dlls/d3d8/tests/visual.c  | 86 +++++++++++++++++++++++++++++++++++++----------
 dlls/d3d9/tests/visual.c  | 86 +++++++++++++++++++++++++++++++++++++----------
 dlls/ddraw/tests/ddraw7.c | 73 +++++++++++++++++++++++++++++++---------
 3 files changed, 193 insertions(+), 52 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 1cd066c..ec406f1 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -5381,33 +5381,69 @@ static void test_negative_fixedfunction_fog(void)
         {{ 1.0f, -1.0f, -0.5f}, 0xffff0000},
         {{ 1.0f,  1.0f, -0.5f}, 0xffff0000},
     };
+    static const struct
+    {
+        struct vec4 position;
+        D3DCOLOR diffuse;
+    }
+    tquad[] =
+    {
+        {{  0.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{  0.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+    };
     unsigned int i;
+    static const D3DMATRIX zero =
+    {{{
+        1.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 1.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 1.0f
+    }}};
+    /* Needed to make AMD drivers happy. Yeah, it is not supposed to
+     * have an effect on RHW draws. */
+    static const 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
+    }}};
     static const struct
     {
+        DWORD pos_type;
+        const void *quad;
+        size_t stride;
+        const D3DMATRIX *matrix;
         union
         {
             float f;
             DWORD d;
         } start, end;
-        D3DFOGMODE vfog;
-        DWORD color;
+        D3DFOGMODE vfog, tfog;
+        DWORD color, color_broken;
     }
     tests[] =
     {
+        /* Run the XYZRHW tests first. Depth clamping is broken after RHW draws on the testbot. */
+        {D3DFVF_XYZRHW, tquad,  sizeof(*tquad), &identity, { 0.0f}, {1.0f},
+                D3DFOG_NONE,   D3DFOG_LINEAR, 0x00ff0000, 0x00ff0000},
+        /* r200 GPUs and presumably all d3d8 and older HW clamp the fog
+         * parameters to 0.0 and 1.0 in the table fog case. */
+        {D3DFVF_XYZRHW, tquad,  sizeof(*tquad), &identity, {-1.0f}, {0.0f},
+                D3DFOG_NONE,   D3DFOG_LINEAR, 0x00808000, 0x00ff0000},
         /* fog_interpolation_test shows that vertex fog evaluates the fog
          * equation in the vertex pipeline. Start = -1.0 && end = 0.0 shows
          * that the abs happens before the fog equation is evaluated. */
-        {{ 0.0f}, {1.0f}, D3DFOG_LINEAR,    0x00808000},
-        {{-1.0f}, {0.0f}, D3DFOG_LINEAR,    0x0000ff00},
-        {{ 0.0f}, {1.0f}, D3DFOG_EXP,       0x009b6400},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     { 0.0f}, {1.0f},
+                D3DFOG_LINEAR, D3DFOG_NONE,   0x00808000, 0x00808000},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     {-1.0f}, {0.0f},
+                D3DFOG_LINEAR, D3DFOG_NONE,   0x0000ff00, 0x0000ff00},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     { 0.0f}, {1.0f},
+                D3DFOG_EXP,    D3DFOG_NONE,   0x009b6400, 0x009b6400},
     };
-    static const D3DMATRIX proj_mat =
-    {{{
-        1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 1.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-    }}};
+    D3DCAPS8 caps;
 
     window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
             0, 0, 640, 480, NULL, NULL, NULL, NULL);
@@ -5422,8 +5458,11 @@ static void test_negative_fixedfunction_fog(void)
         return;
     }
 
-    hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
+        skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests.\n");
+
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
@@ -5432,29 +5471,40 @@ static void test_negative_fixedfunction_fog(void)
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
-    hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
 
     for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
     {
+        if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+            continue;
+
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
         ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
 
+        hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, tests[i].matrix);
+        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+        hr = IDirect3DDevice8_SetVertexShader(device, tests[i].pos_type | D3DFVF_DIFFUSE);
+        ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGSTART, tests[i].start.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, tests[i].end.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
         hr = IDirect3DDevice8_BeginScene(device);
         ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
-        hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+        hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, tests[i].quad, tests[i].stride);
         ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
         hr = IDirect3DDevice8_EndScene(device);
         ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
 
         color = getPixelColor(device, 320, 240);
-        ok(color_match(color, tests[i].color, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+        ok(color_match(color, tests[i].color, 2) || broken(color_match(color, tests[i].color_broken, 2)),
+                "Got unexpected color 0x%08x, case %u.\n", color, i);
         hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
         ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
     }
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 6bf9adc..59f5ba8 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -16984,33 +16984,69 @@ static void test_negative_fixedfunction_fog(void)
         {{ 1.0f, -1.0f, -0.5f}, 0xffff0000},
         {{ 1.0f,  1.0f, -0.5f}, 0xffff0000},
     };
+    static const struct
+    {
+        struct vec4 position;
+        D3DCOLOR diffuse;
+    }
+    tquad[] =
+    {
+        {{  0.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{  0.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+    };
     unsigned int i;
+    static const D3DMATRIX zero =
+    {{{
+        1.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 1.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 1.0f
+    }}};
+    /* Needed to make AMD drivers happy. Yeah, it is not supposed to
+     * have an effect on RHW draws. */
+    static const 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
+    }}};
     static const struct
     {
+        DWORD pos_type;
+        const void *quad;
+        size_t stride;
+        const D3DMATRIX *matrix;
         union
         {
             float f;
             DWORD d;
         } start, end;
-        D3DFOGMODE vfog;
-        DWORD color;
+        D3DFOGMODE vfog, tfog;
+        DWORD color, color_broken;
     }
     tests[] =
     {
+        /* Run the XYZRHW tests first. Depth clamping is broken after RHW draws on the testbot. */
+        {D3DFVF_XYZRHW, tquad,  sizeof(*tquad), &identity, { 0.0f}, {1.0f},
+                D3DFOG_NONE,   D3DFOG_LINEAR, 0x00ff0000, 0x00ff0000},
+        /* r200 GPUs and presumably all d3d8 and older HW clamp the fog
+         * parameters to 0.0 and 1.0 in the table fog case. */
+        {D3DFVF_XYZRHW, tquad,  sizeof(*tquad), &identity, {-1.0f}, {0.0f},
+                D3DFOG_NONE,   D3DFOG_LINEAR, 0x00808000, 0x00ff0000},
         /* fog_interpolation_test shows that vertex fog evaluates the fog
          * equation in the vertex pipeline. Start = -1.0 && end = 0.0 shows
          * that the abs happens before the fog equation is evaluated. */
-        {{ 0.0f}, {1.0f}, D3DFOG_LINEAR,    0x00808000},
-        {{-1.0f}, {0.0f}, D3DFOG_LINEAR,    0x0000ff00},
-        {{ 0.0f}, {1.0f}, D3DFOG_EXP,       0x009b6400},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     { 0.0f}, {1.0f},
+                D3DFOG_LINEAR, D3DFOG_NONE,   0x00808000, 0x00808000},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     {-1.0f}, {0.0f},
+                D3DFOG_LINEAR, D3DFOG_NONE,   0x0000ff00, 0x0000ff00},
+        {D3DFVF_XYZ,    quad,   sizeof(*quad),  &zero,     { 0.0f}, {1.0f},
+                D3DFOG_EXP,    D3DFOG_NONE,   0x009b6400, 0x009b6400},
     };
-    static const D3DMATRIX proj_mat =
-    {{{
-        1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 1.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-    }}};
+    D3DCAPS9 caps;
 
     window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
             0, 0, 640, 480, NULL, NULL, NULL, NULL);
@@ -17025,8 +17061,11 @@ static void test_negative_fixedfunction_fog(void)
         return;
     }
 
-    hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
+        skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests.\n");
+
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
@@ -17035,29 +17074,40 @@ static void test_negative_fixedfunction_fog(void)
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
-    hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
 
     for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
     {
+        if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+            continue;
+
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
         ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
 
+        hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, tests[i].matrix);
+        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+        hr = IDirect3DDevice9_SetFVF(device, tests[i].pos_type | D3DFVF_DIFFUSE);
+        ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, tests[i].start.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, tests[i].end.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
         hr = IDirect3DDevice9_BeginScene(device);
         ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
-        hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+        hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, tests[i].quad, tests[i].stride);
         ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
         ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
 
         color = getPixelColor(device, 320, 240);
-        ok(color_match(color, tests[i].color, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+        ok(color_match(color, tests[i].color, 2) || broken(color_match(color, tests[i].color_broken, 2)),
+                "Got unexpected color 0x%08x, case %u.\n", color, i);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
         ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
     }
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index a1dbd5e..e9510c4 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -8022,33 +8022,61 @@ static void test_negative_fixedfunction_fog(void)
         {{ 1.0f, -1.0f, -0.5f}, 0xffff0000},
         {{ 1.0f,  1.0f, -0.5f}, 0xffff0000},
     };
+    static struct
+    {
+        struct vec4 position;
+        D3DCOLOR diffuse;
+    }
+    tquad[] =
+    {
+        {{  0.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f,   0.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{  0.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+        {{640.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
+    };
     unsigned int i;
+    static D3DMATRIX zero =
+    {
+        1.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 1.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 1.0f
+    };
+    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
+    };
     static const struct
     {
+        DWORD pos_type;
+        void *quad;
+        D3DMATRIX *matrix;
         union
         {
             float f;
             DWORD d;
         } start, end;
-        D3DFOGMODE vfog;
-        DWORD color;
+        D3DFOGMODE vfog, tfog;
+        DWORD color, color_broken;
     }
     tests[] =
     {
+        /* Run the XYZRHW tests first. Depth clamping is broken after RHW draws on the testbot. */
+        {D3DFVF_XYZRHW, tquad,  &identity, { 0.0f}, {1.0f}, D3DFOG_NONE,   D3DFOG_LINEAR, 0x00ff0000, 0x00ff0000},
+        /* r200 GPUs and presumably all d3d8 and older HW clamp the fog
+         * parameters to 0.0 and 1.0 in the table fog case. */
+        {D3DFVF_XYZRHW, tquad,  &identity, {-1.0f}, {0.0f}, D3DFOG_NONE,   D3DFOG_LINEAR, 0x00808000, 0x00ff0000},
         /* fog_interpolation_test shows that vertex fog evaluates the fog
          * equation in the vertex pipeline. Start = -1.0 && end = 0.0 shows
          * that the abs happens before the fog equation is evaluated. */
-        {{ 0.0f}, {1.0f}, D3DFOG_LINEAR,    0x00808000},
-        {{-1.0f}, {0.0f}, D3DFOG_LINEAR,    0x0000ff00},
-        {{ 0.0f}, {1.0f}, D3DFOG_EXP,       0x009b6400},
-    };
-    static D3DMATRIX proj_mat =
-    {
-        1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 1.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
+        {D3DFVF_XYZ,    quad,   &zero,     { 0.0f}, {1.0f}, D3DFOG_LINEAR, D3DFOG_NONE,   0x00808000, 0x00808000},
+        {D3DFVF_XYZ,    quad,   &zero,     {-1.0f}, {0.0f}, D3DFOG_LINEAR, D3DFOG_NONE,   0x0000ff00, 0x0000ff00},
+        {D3DFVF_XYZ,    quad,   &zero,     { 0.0f}, {1.0f}, D3DFOG_EXP,    D3DFOG_NONE,   0x009b6400, 0x009b6400},
     };
+    D3DDEVICEDESC7 caps;
 
     window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
             0, 0, 640, 480, 0, 0, 0, 0);
@@ -8062,6 +8090,10 @@ static void test_negative_fixedfunction_fog(void)
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
     ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    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 some fog tests.\n");
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
     ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
@@ -8071,29 +8103,38 @@ static void test_negative_fixedfunction_fog(void)
     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_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
 
     for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
     {
+        if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+            continue;
+
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
         ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
 
+        hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, tests[i].matrix);
+        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART, tests[i].start.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, tests[i].end.d);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, tests[i].vfog);
         ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, tests[i].tfog);
+        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_XYZ | D3DFVF_DIFFUSE, quad, 4, 0);
+                tests[i].pos_type | D3DFVF_DIFFUSE, tests[i].quad, 4, 0);
         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, case %u.\n", color, i);
+        ok(compare_color(color, tests[i].color, 2) || broken(compare_color(color, tests[i].color_broken, 2)),
+                "Got unexpected color 0x%08x, case %u.\n", color, i);
     }
 
     IDirectDrawSurface7_Release(rt);
-- 
2.0.4




More information about the wine-patches mailing list