From 462bbf4d20b7c80e5595e15e426f90b6e4cac4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Sat, 2 Dec 2017 10:24:37 +0100 Subject: [PATCH] ddraw/tests: Add test for clip planes limits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/ddraw/tests/ddraw7.c | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 00c7919049e..17abdf4d44a 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -13297,6 +13297,82 @@ static void test_compute_sphere_visibility(void) DestroyWindow(window); } +static void test_clip_planes_limits(void) +{ + IDirect3DDevice7 *device; + D3DDEVICEDESC7 caps; + unsigned int i; + ULONG refcount; + float plane[4]; + 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; + } + + memset(&caps, 0, sizeof(caps)); + hr = IDirect3DDevice7_GetCaps(device, &caps); + ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr); + + trace("Max user clip planes: %u.\n", caps.wMaxUserClipPlanes); + + for (i = 0; i < D3DMAXUSERCLIPPLANES; ++i) + { + memset(plane, 0xff, sizeof(plane)); + hr = IDirect3DDevice7_GetClipPlane(device, i, plane); + todo_wine_if(i >= caps.wMaxUserClipPlanes) + { + ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", i, hr); + ok(!plane[0] && !plane[1] && !plane[2] && !plane[3], + "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n", + i, plane[0], plane[1], plane[2], plane[3]); + } + } + + plane[0] = 2.0f; + plane[1] = 8.0f; + plane[2] = 5.0f; + for (i = 0; i < D3DMAXUSERCLIPPLANES; ++i) + { + plane[3] = i; + hr = IDirect3DDevice7_SetClipPlane(device, i, plane); + todo_wine_if(i >= caps.wMaxUserClipPlanes) + ok(hr == D3D_OK, "Failed to set clip plane %u, hr %#x.\n", i, hr); + } + for (i = 0; i < D3DMAXUSERCLIPPLANES; ++i) + { + memset(plane, 0xff, sizeof(plane)); + hr = IDirect3DDevice7_GetClipPlane(device, i, plane); + todo_wine_if(i >= caps.wMaxUserClipPlanes) + ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", i, hr); + todo_wine_if(i >= caps.wMaxUserClipPlanes) + ok(plane[0] == 2.0f && plane[1] == 8.0f && plane[2] == 5.0f && plane[3] == i, + "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n", + i, plane[0], plane[1], plane[2], plane[3]); + } + + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, 0xffffffff); + ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr); + hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, &state); + ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(state == 0xffffffff, "Got unexpected state %#x.\n", state); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, 0x80000000); + ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr); + hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, &state); + ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(state == 0x80000000, "Got unexpected state %#x.\n", state); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { HMODULE module = GetModuleHandleA("ddraw.dll"); @@ -13414,4 +13490,5 @@ START_TEST(ddraw7) test_ck_operation(); test_vb_refcount(); test_compute_sphere_visibility(); + test_clip_planes_limits(); }