Commit b93814e9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8/tests: Add a test for INTZ.

parent f0b0c1b1
......@@ -1556,6 +1556,195 @@ static void depth_buffer_test(IDirect3DDevice8 *device)
ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
}
static void intz_test(IDirect3DDevice8 *device)
{
static const DWORD ps_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000051, 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 1.0, 0.0, 0.0, 0.0 */
0x00000051, 0xa00f0001, 0x00000000, 0x3f800000, 0x00000000, 0x00000000, /* def c1, 0.0, 1.0, 0.0, 0.0 */
0x00000051, 0xa00f0002, 0x00000000, 0x00000000, 0x3f800000, 0x00000000, /* def c2, 0.0, 0.0, 1.0, 0.0 */
0x00000042, 0xb00f0000, /* tex t0 */
0x00000042, 0xb00f0001, /* tex t1 */
0x00000008, 0xb0070001, 0xa0e40000, 0xb0e40001, /* dp3 t1.xyz, c0, t1 */
0x00000005, 0x80070000, 0xa0e40001, 0xb0e40001, /* mul r0.xyz, c1, t1 */
0x00000004, 0x80070000, 0xa0e40000, 0xb0e40000, 0x80e40000, /* mad r0.xyz, c0, t0, r0 */
0x40000001, 0x80080000, 0xa0aa0002, /* +mov r0.w, c2.z */
0x0000ffff, /* end */
};
struct
{
float x, y, z;
float s0, t0, p0;
float s1, t1, p1, q1;
}
quad[] =
{
{ -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f},
{ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f},
{ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
};
struct
{
UINT x, y;
D3DCOLOR color;
}
expected_colors[] =
{
{400, 60, D3DCOLOR_ARGB(0x00, 0x9f, 0xff, 0x00)},
{560, 180, D3DCOLOR_ARGB(0x00, 0xdf, 0x55, 0x00)},
{560, 300, D3DCOLOR_ARGB(0x00, 0xdf, 0x66, 0x00)},
{400, 420, D3DCOLOR_ARGB(0x00, 0x9f, 0xb6, 0x00)},
{240, 420, D3DCOLOR_ARGB(0x00, 0x60, 0x6d, 0x00)},
{ 80, 300, D3DCOLOR_ARGB(0x00, 0x20, 0x33, 0x00)},
{ 80, 180, D3DCOLOR_ARGB(0x00, 0x20, 0x55, 0x00)},
{240, 60, D3DCOLOR_ARGB(0x00, 0x60, 0xff, 0x00)},
};
IDirect3DSurface8 *original_ds, *original_rt, *rt;
IDirect3DTexture8 *texture;
IDirect3DSurface8 *ds;
IDirect3D8 *d3d8;
D3DCAPS8 caps;
HRESULT hr;
DWORD ps;
UINT i;
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
{
skip("No pixel shader 1.1 support, skipping INTZ test.\n");
return;
}
hr = IDirect3DDevice8_GetDirect3D(device, &d3d8);
ok(SUCCEEDED(hr), "GetDirect3D failed, hr %#x.\n", hr);
hr = IDirect3D8_CheckDeviceFormat(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, MAKEFOURCC('I','N','T','Z'));
if (FAILED(hr))
{
skip("No INTZ support, skipping INTZ test.\n");
return;
}
IDirect3D8_Release(d3d8);
hr = IDirect3DDevice8_GetRenderTarget(device, &original_rt);
ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &original_ds);
ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreateTexture(device, 1024, 1024, 1,
D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture);
ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreateRenderTarget(device, 1024, 1024, D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE, FALSE, &rt);
ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps);
ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX2
| D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE4(1));
ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MINFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds);
ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
IDirect3DDevice8_SetPixelShader(device, 0);
ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
/* Setup the depth/stencil surface. */
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_BeginScene(device);
ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, NULL);
ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
IDirect3DSurface8_Release(ds);
hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetPixelShader(device, ps);
ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
/* Read the depth values back. */
hr = IDirect3DDevice8_BeginScene(device);
ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
{
D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
"Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
}
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, original_ds);
ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
IDirect3DSurface8_Release(original_ds);
hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTexture(device, 1, NULL);
ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
IDirect3DTexture8_Release(texture);
hr = IDirect3DDevice8_SetPixelShader(device, 0);
ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_DeletePixelShader(device, ps);
ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#x.\n", hr);
IDirect3DSurface8_Release(original_rt);
IDirect3DSurface8_Release(rt);
}
static void shadow_test(IDirect3DDevice8 *device)
{
static const DWORD ps_code[] =
......@@ -1844,6 +2033,7 @@ START_TEST(visual)
p8_texture_test(device_ptr);
texop_test(device_ptr);
depth_buffer_test(device_ptr);
intz_test(device_ptr);
shadow_test(device_ptr);
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