[PATCH 3/5] d3d9/tests: Add a test for fog_start == fog_end (try 2)
Stefan Dösinger
stefan at codeweavers.com
Mon Jun 17 15:53:23 CDT 2013
try 2: Check the colors before calling present so we don't rely on
D3DSWAPEFFECT_COPY.
The behavior is consistent among all Windows drivers I tested (r200+xp,
geforce7+vista, r500+win7, r600+win7, geforce9+win7). Windows drivers
disagree on fog_coord==fog_start==fog_end in the table fog case though,
so the test does not test that.
---
dlls/d3d9/tests/visual.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 166 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 32470f0..dc84559 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -14038,6 +14038,171 @@ static void zenable_test(IDirect3DDevice9 *device)
}
}
+static void fog_special_test(IDirect3DDevice9 *device)
+{
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ }
+ quad[] =
+ {
+ {{ -1.0f, -1.0f, 0.0f}, 0xff00ff00},
+ {{ 1.0f, -1.0f, 1.0f}, 0xff00ff00},
+ {{ -1.0f, 1.0f, 0.0f}, 0xff00ff00},
+ {{ 1.0f, 1.0f, 1.0f}, 0xff00ff00}
+ };
+ static const struct
+ {
+ DWORD vertexmode, tablemode;
+ BOOL vs, ps;
+ D3DCOLOR color_left, color_right;
+ }
+ tests[] =
+ {
+ {D3DFOG_LINEAR, D3DFOG_NONE, FALSE, FALSE, 0x00ff0000, 0x00ff0000},
+ {D3DFOG_LINEAR, D3DFOG_NONE, FALSE, TRUE, 0x00ff0000, 0x00ff0000},
+ {D3DFOG_LINEAR, D3DFOG_NONE, TRUE, FALSE, 0x00ff0000, 0x00ff0000},
+ {D3DFOG_LINEAR, D3DFOG_NONE, TRUE, TRUE, 0x00ff0000, 0x00ff0000},
+
+ {D3DFOG_NONE, D3DFOG_LINEAR, FALSE, FALSE, 0x0000ff00, 0x00ff0000},
+ {D3DFOG_NONE, D3DFOG_LINEAR, FALSE, TRUE, 0x0000ff00, 0x00ff0000},
+ {D3DFOG_NONE, D3DFOG_LINEAR, TRUE, FALSE, 0x0000ff00, 0x00ff0000},
+ {D3DFOG_NONE, D3DFOG_LINEAR, TRUE, TRUE, 0x0000ff00, 0x00ff0000},
+ };
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+ static const DWORD vertex_shader_code[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff
+ };
+ union
+ {
+ float f;
+ DWORD d;
+ } conv;
+ DWORD color;
+ HRESULT hr;
+ unsigned int i;
+ IDirect3DPixelShader9 *ps;
+ IDirect3DVertexShader9 *vs;
+ D3DCAPS9 caps;
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+ if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code, &vs);
+ ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+ }
+ else
+ {
+ skip("Vertex Shaders not supported, skipping some fog tests.\n");
+ vs = NULL;
+ }
+ if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 1))
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ }
+ else
+ {
+ skip("Pixel Shaders not supported, skipping some fog tests.\n");
+ ps = NULL;
+ }
+
+ hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0xffff0000);
+ ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+
+ conv.f = 0.5f;
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, conv.d);
+ ok(SUCCEEDED(hr), "Failed to set fog start, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, conv.d);
+ ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ {
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+
+ if (!tests[i].vs)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, NULL);
+ ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+ }
+ else if (vs)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, vs);
+ ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+ }
+ else
+ {
+ continue;
+ }
+
+ if (!tests[i].ps)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, NULL);
+ ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+ }
+ else if (ps)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, ps);
+ ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+ }
+ else
+ {
+ continue;
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vertexmode);
+ ok(SUCCEEDED(hr), "Failed to set fogvertexmode, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tablemode);
+ ok(SUCCEEDED(hr), "Failed to set fogtablemode, 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));
+ 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, 310, 240);
+ ok(color_match(color, tests[i].color_left, 1),
+ "Expected left color 0x%08x, got 0x%08x, case %u.\n", tests[i].color_left, color, i);
+ color = getPixelColor(device, 330, 240);
+ ok(color_match(color, tests[i].color_right, 1),
+ "Expected right color 0x%08x, got 0x%08x, case %u.\n", tests[i].color_right, color, i);
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetPixelShader(device, NULL);
+ ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetVertexShader(device, NULL);
+ ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+ if (vs)
+ IDirect3DVertexShader9_Release(vs);
+ if (ps)
+ IDirect3DPixelShader9_Release(ps);
+}
+
START_TEST(visual)
{
IDirect3D9 *d3d9;
@@ -14215,6 +14380,7 @@ START_TEST(visual)
update_surface_test(device_ptr);
multisample_get_rtdata_test(device_ptr);
zenable_test(device_ptr);
+ fog_special_test(device_ptr);
hr = IDirect3DDevice9_GetDirect3D(device_ptr, &d3d9);
ok(SUCCEEDED(hr), "Failed to get d3d9 interface, hr %#x.\n", hr);
--
1.8.1.5
More information about the wine-patches
mailing list