Commit 4e9cf000 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8/tests: Add tests for z-clipping with D3DRS_ZENABLE disabled.

parent 19199bc5
...@@ -25,6 +25,16 @@ ...@@ -25,6 +25,16 @@
static HMODULE d3d8_handle = 0; static HMODULE d3d8_handle = 0;
struct vec3
{
float x, y, z;
};
struct vec4
{
float x, y, z, w;
};
static HWND create_window(void) static HWND create_window(void)
{ {
WNDCLASS wc = {0}; WNDCLASS wc = {0};
...@@ -2766,6 +2776,140 @@ static void resz_test(IDirect3DDevice8 *device) ...@@ -2766,6 +2776,140 @@ static void resz_test(IDirect3DDevice8 *device)
IDirect3DSurface8_Release(original_rt); IDirect3DSurface8_Release(original_rt);
} }
static void zenable_test(IDirect3DDevice8 *device)
{
static const struct
{
struct vec4 position;
D3DCOLOR diffuse;
}
tquad[] =
{
{{ 0.0f, 480.0f, -0.5f, 1.0f}, 0xff00ff00},
{{ 0.0f, 0.0f, -0.5f, 1.0f}, 0xff00ff00},
{{640.0f, 480.0f, 1.5f, 1.0f}, 0xff00ff00},
{{640.0f, 0.0f, 1.5f, 1.0f}, 0xff00ff00},
};
D3DCOLOR color;
D3DCAPS8 caps;
HRESULT hr;
UINT x, y;
UINT i, j;
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, 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, tquad, sizeof(*tquad));
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);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = getPixelColor(device, x, y);
ok(color_match(color, 0x0000ff00, 1),
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
}
}
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 1)
&& caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
{
static const DWORD vs_code[] =
{
0xfffe0101, /* vs_1_1 */
0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
0x00000001, 0xd00f0000, 0x90e40000, /* mov oD0, v0 */
0x0000ffff
};
static const DWORD ps_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
0x0000ffff /* end */
};
static const struct vec3 quad[] =
{
{-1.0f, -1.0f, -0.5f},
{-1.0f, 1.0f, -0.5f},
{ 1.0f, -1.0f, 1.5f},
{ 1.0f, 1.0f, 1.5f},
};
static const D3DCOLOR expected[] =
{
0x00ff0000, 0x0060df60, 0x009fdf9f, 0x00ff0000,
0x00ff0000, 0x00609f60, 0x009f9f9f, 0x00ff0000,
0x00ff0000, 0x00606060, 0x009f609f, 0x00ff0000,
0x00ff0000, 0x00602060, 0x009f209f, 0x00ff0000,
};
static const DWORD decl[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3),
D3DVSD_END()
};
DWORD vs, ps;
hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_code, &vs, 0);
ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetVertexShader(device, vs);
ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetPixelShader(device, ps);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, 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));
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);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = getPixelColor(device, x, y);
ok(color_match(color, expected[i * 4 + j], 1),
"Expected color 0x%08x at %u, %u, got 0x%08x.\n", expected[i * 4 + j], x, y, color);
}
}
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetPixelShader(device, 0);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetVertexShader(device, 0);
ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_DeletePixelShader(device, ps);
ok(SUCCEEDED(hr), "Failed to delete pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice8_DeleteVertexShader(device, vs);
ok(SUCCEEDED(hr), "Failed to delete vertex shader, hr %#x.\n", hr);
}
}
START_TEST(visual) START_TEST(visual)
{ {
IDirect3DDevice8 *device_ptr; IDirect3DDevice8 *device_ptr;
...@@ -2845,6 +2989,7 @@ START_TEST(visual) ...@@ -2845,6 +2989,7 @@ START_TEST(visual)
intz_test(device_ptr); intz_test(device_ptr);
shadow_test(device_ptr); shadow_test(device_ptr);
multisample_copy_rects_test(device_ptr); multisample_copy_rects_test(device_ptr);
zenable_test(device_ptr);
resz_test(device_ptr); resz_test(device_ptr);
cleanup: cleanup:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment