From 5604c7ed99f52b55e6725dbe6d9bcd9843592398 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Thu, 12 Jan 2012 17:05:17 +0100 Subject: [PATCH] d3d8/tests: Add more INTZ tests. --- dlls/d3d8/tests/visual.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index c221d470508..dcaa091a41e 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -1854,6 +1854,20 @@ static void intz_test(IDirect3DDevice8 *device) { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f}, { -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f}, { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f}, + }, + half_quad_1[] = + { + { -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.5f}, + { 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f}, + { -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f}, + { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f}, + }, + half_quad_2[] = + { + { -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.5f}, + { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f}, + { -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f}, + { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f}, }; struct { @@ -1888,6 +1902,11 @@ static void intz_test(IDirect3DDevice8 *device) skip("No pixel shader 1.1 support, skipping INTZ test.\n"); return; } + if (caps.TextureCaps & D3DPTEXTURECAPS_POW2) + { + skip("No unconditional NP2 texture support, skipping INTZ test.\n"); + return; + } hr = IDirect3DDevice8_GetDirect3D(device, &d3d8); ok(SUCCEEDED(hr), "GetDirect3D failed, hr %#x.\n", hr); @@ -1907,10 +1926,10 @@ static void intz_test(IDirect3DDevice8 *device) hr = IDirect3DDevice8_GetDepthStencilSurface(device, &original_ds); ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr); - hr = IDirect3DDevice8_CreateTexture(device, 1024, 1024, 1, + hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 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, + hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt); ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps); @@ -1953,6 +1972,8 @@ static void intz_test(IDirect3DDevice8 *device) hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds); ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr); + + /* Render offscreen, using the INTZ texture as depth buffer */ hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds); ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr); IDirect3DDevice8_SetPixelShader(device, 0); @@ -1998,6 +2019,128 @@ static void intz_test(IDirect3DDevice8 *device) hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr); + 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); + + /* Render onscreen while using the INTZ texture as depth buffer */ + hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1, + D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture); + ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds); + ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, ds); + ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr); + IDirect3DDevice8_SetPixelShader(device, 0); + ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr); + + 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_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); + + /* Render offscreen, then onscreen, and finally check the INTZ texture in both areas */ + hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1, + D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture); + ok(SUCCEEDED(hr), "CreateTexture 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); + + 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, half_quad_1, sizeof(*half_quad_1)); + 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, ds); + ok(SUCCEEDED(hr), "SetRenderTarget 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, half_quad_2, sizeof(*half_quad_2)); + 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); -- 2.11.4.GIT