Module: wine Branch: master Commit: 110eecf7d48688b573f4215f84ff8ad464f40da8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=110eecf7d48688b573f4215f8...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Jan 11 15:33:33 2018 +0100
ddraw/tests: Rewrite SetRenderState() tests.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ddraw/tests/d3d.c | 30 ------------------------------ dlls/ddraw/tests/ddraw2.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c | 39 +++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 30 deletions(-)
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 205a4c6..77836fd 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -411,18 +411,6 @@ static void LightTest(void) } }
-static void StateTest( void ) -{ - HRESULT rc; - - /* The msdn says it's undocumented, does it return an error too? */ - rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, TRUE); - ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, TRUE) returned %08x\n", rc); - rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, FALSE); - ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, FALSE) returned %08x\n", rc); -} - - static void SceneTest(void) { HRESULT hr; @@ -1416,22 +1404,6 @@ out: IDirect3DVertexBuffer7_Release(lpVBufSrc); }
-static void D3D7_OldRenderStateTest(void) -{ - HRESULT hr; - DWORD val; - - /* Test reaction to some deprecated states in D3D7. */ - hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, 0); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr); - hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, &val); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr); - hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr); - hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, &val); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr); -} - #define IS_VALUE_NEAR(a, b) ( ((a) == (b)) || ((a) == (b) - 1) || ((a) == (b) + 1) ) #define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -3444,14 +3416,12 @@ START_TEST(d3d) skip("Skipping d3d7 tests\n"); } else { LightTest(); - StateTest(); SceneTest(); D3D7EnumTest(); D3D7EnumLifetimeTest(); SetMaterialTest(); CapsTest(); VertexBufferDescTest(); - D3D7_OldRenderStateTest(); DeviceLoadTest(); SetRenderTargetTest(); VertexBufferLockRest(); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index cc1ed70..faf7cef 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -12166,6 +12166,49 @@ done: DestroyWindow(window); }
+static void test_set_render_state(void) +{ + IDirect3DDevice2 *device; + IDirectDraw2 *ddraw; + ULONG refcount; + HWND window; + DWORD state; + HRESULT hr; + + window = create_window(); + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + if (!(device = create_device(ddraw, window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + state = 0xdeadbeef; + hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!state, "Got unexpected render state %#x.\n", state); + hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state); + + refcount = IDirect3DDevice2_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDirectDraw2_Release(ddraw); + ok(!refcount, "DirectDraw has %u references left.\n", refcount); + DestroyWindow(window); +} + static void test_depth_readback(void) { DWORD depth, expected_depth, max_diff; @@ -12697,6 +12740,7 @@ START_TEST(ddraw2) test_display_mode_surface_pixel_format(); test_surface_desc_size(); test_ck_operation(); + test_set_render_state(); test_depth_readback(); test_clear(); test_enum_surfaces(); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index fb030a8..1f0b01b 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -14077,6 +14077,44 @@ static void test_texture_stages_limits(void) DestroyWindow(window); }
+static void test_set_render_state(void) +{ + IDirect3DDevice3 *device; + ULONG refcount; + HWND window; + DWORD state; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + state = 0xdeadbeef; + hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!state, "Got unexpected render state %#x.\n", state); + hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state); + + refcount = IDirect3DDevice3_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + static void test_map_synchronisation(void) { LARGE_INTEGER frequency, diff, ts[3]; @@ -14819,6 +14857,7 @@ START_TEST(ddraw4) test_vb_refcount(); test_compute_sphere_visibility(); test_texture_stages_limits(); + test_set_render_state(); test_map_synchronisation(); test_depth_readback(); test_clear(); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index a61c9c2..2e41ff3 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -13449,6 +13449,46 @@ static void test_texture_stages_limits(void) DestroyWindow(window); }
+static void test_set_render_state(void) +{ + IDirect3DDevice7 *device; + ULONG refcount; + HWND window; + DWORD state; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + /* States deprecated in D3D7 */ + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + state = 0xdeadbeef; + hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + state = 0xdeadbeef; + hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + static void test_map_synchronisation(void) { LARGE_INTEGER frequency, diff, ts[3]; @@ -14157,6 +14197,7 @@ START_TEST(ddraw7) test_compute_sphere_visibility(); test_clip_planes_limits(); test_texture_stages_limits(); + test_set_render_state(); test_map_synchronisation(); test_depth_readback(); test_clear();