From f73d82d694495ffd695866a1f85786d556c71bc5 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 19 Jun 2010 23:26:40 +0200 Subject: [PATCH] d3d9: add test for SetRenderState(D3DRS_ZENABLE, 255) --- dlls/d3d9/tests/visual.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 1da7cca..bf978db 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -10369,6 +10369,55 @@ static void zwriteenable_test(IDirect3DDevice9 *device) { ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); } +static void zenable_unknown_value_test(IDirect3DDevice9 *device) { + const unsigned zenable_val = 255; + HRESULT hr; + DWORD color; + struct vertex quad[] = { + { -1.0, -1.0, 0.1, 0x00ff0000}, + { -1.0, 1.0, 0.1, 0x00ff0000}, + { 1.0, -1.0, 0.1, 0x00ff0000}, + { 1.0, 1.0, 0.1, 0x00ff0000}, + }; + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ffffff, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, zenable_val); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with 0x%08x\n", hr); + if(SUCCEEDED(hr)) { + /* Check that SetRenderState(D3DRS_ZENABLE, 255) enabled depth buffering + * and the quad is NOT drawn + */ + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad)); + ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with 0x%08x\n", hr); + } + + color = getPixelColor(device, 320, 240); + ok(color_match(color, 0x00ffffff, 1), "zenable_unknown_value_test test returned 0x%08x, expected 0x00ffffff\n", + color); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr); +} + static void alphatest_test(IDirect3DDevice9 *device) { #define ALPHATEST_PASSED 0x0000ff00 #define ALPHATEST_FAILED 0x00ff0000 @@ -11356,6 +11405,7 @@ START_TEST(visual) np2_stretch_rect_test(device_ptr); yuv_color_test(device_ptr); zwriteenable_test(device_ptr); + zenable_unknown_value_test(device_ptr); alphatest_test(device_ptr); viewport_test(device_ptr); -- 1.7.0.4