Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This is essentially a proposal for a new manner of testing stateblocks. I find this distinctly easier to read than existing stateblock tests for d3d8/9. It also is more flexible for testing interactions between different states (e.g. light parameters / enabled state in patch 4/4). If this is preferred I would also propose to port d3d8/9 stateblock tests to this structure.
dlls/ddraw/tests/ddraw7.c | 316 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 5f066a6257..69eba24f99 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -15893,6 +15893,321 @@ static void test_begin_end_state_block(void) DestroyWindow(window); }
+static void test_transform_state(void) +{ + D3DMATRIX mat1, mat2, ret_mat; + IDirect3DDevice7 *device; + DWORD stateblock; + unsigned int i; + ULONG refcount; + HWND window; + HRESULT hr; + + static const D3DTRANSFORMSTATETYPE tests[] = + { + D3DTRANSFORMSTATE_WORLD, + D3DTRANSFORMSTATE_VIEW, + D3DTRANSFORMSTATE_PROJECTION, + D3DTRANSFORMSTATE_WORLD1, + D3DTRANSFORMSTATE_WORLD2, + D3DTRANSFORMSTATE_WORLD3, + D3DTRANSFORMSTATE_TEXTURE0, + D3DTRANSFORMSTATE_TEXTURE1, + D3DTRANSFORMSTATE_TEXTURE2, + D3DTRANSFORMSTATE_TEXTURE3, + D3DTRANSFORMSTATE_TEXTURE4, + D3DTRANSFORMSTATE_TEXTURE5, + D3DTRANSFORMSTATE_TEXTURE6, + D3DTRANSFORMSTATE_TEXTURE7, + }; + + static const D3DMATRIX identity = + { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + }; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + memset(&mat1, 0x11, sizeof(mat1)); + memset(&mat2, 0x22, sizeof(mat2)); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &identity, sizeof(identity)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + /* Recorded stateblock, even states. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + if (i % 2) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + } + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, (i % 2) ? &mat2 : &mat1, sizeof(mat1)), + "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, (i % 2) ? &mat1 : &mat2, sizeof(mat1)), + "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + /* Recorded stateblock, odd states. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + if (!(i % 2)) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + } + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, (i % 2) ? &mat1 : &mat2, sizeof(mat1)), + "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, (i % 2) ? &mat2 : &mat1, sizeof(mat1)), + "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + /* Predefined stateblock, D3DSBT_ALL. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + /* Predefined stateblock, D3DSBT_VERTEXSTATE. The documentation incorrectly + * states that transform matrices are included. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + /* Predefined stateblock, D3DSBT_PIXELSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_PIXELSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat2); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + } + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat); + ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", tests[i], hr); + ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", tests[i]); + } + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -16038,4 +16353,5 @@ START_TEST(ddraw7) test_alphatest(); test_clipper_refcount(); test_begin_end_state_block(); + test_transform_state(); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/tests/ddraw7.c | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 69eba24f99..eccaf86190 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -16208,6 +16208,172 @@ static void test_transform_state(void) DestroyWindow(window); }
+static void test_viewport_state(void) +{ + D3DVIEWPORT7 vp1 = {10, 10, 16, 16, 0.0f, 0.0f}, vp2 = {20, 20, 32, 32, 1.0f, 1.0f}, ret_vp; + IDirect3DDevice7 *device; + DWORD stateblock; + ULONG refcount; + HWND window; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(ret_vp.dwX == 0, "Got unexpected dwX %u.\n", ret_vp.dwX); + ok(ret_vp.dwY == 0, "Got unexpected dwY %u.\n", ret_vp.dwY); + ok(ret_vp.dwWidth == 640, "Got unexpected dwWidth %u.\n", ret_vp.dwWidth); + ok(ret_vp.dwHeight == 480, "Got unexpected dwHeight %u.\n", ret_vp.dwHeight); + ok(ret_vp.dvMinZ == 0.0f, "Got unexpected dvMinZ %.8e.\n", ret_vp.dvMinZ); + ok(ret_vp.dvMaxZ == 1.0f, "Got unexpected dvMaxZ %.8e.\n", ret_vp.dvMaxZ); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Recorded stateblock. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Predefined stateblock, D3DSBT_ALL. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + /* Predefined stateblock, D3DSBT_VERTEXSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Predefined stateblock, D3DSBT_PIXELSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_PIXELSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -16354,4 +16520,5 @@ START_TEST(ddraw7) test_clipper_refcount(); test_begin_end_state_block(); test_transform_state(); + test_viewport_state(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=51972
Your paranoid android.
=== w8 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w8adm (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w864 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w1064 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/tests/ddraw7.c | 182 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index eccaf86190..3dca4dc2da 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -16374,6 +16374,187 @@ static void test_viewport_state(void) DestroyWindow(window); }
+static void test_material_state(void) +{ + D3DMATERIAL7 material1, material2, material; + static const D3DCOLORVALUE null_color; + IDirect3DDevice7 *device; + DWORD stateblock; + ULONG refcount; + HWND window; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(SUCCEEDED(hr), "Failed to get material, hr %#x.\n", hr); + ok(!memcmp(&U(material).diffuse, &null_color, sizeof(null_color)), + "Got unexpected diffuse color {%.8e, %.8e, %.8e, %.8e}.\n", + U1(U(material).diffuse).r, U2(U(material).diffuse).g, + U3(U(material).diffuse).b, U4(U(material).diffuse).a); + ok(!memcmp(&U1(material).ambient, &null_color, sizeof(null_color)), + "Got unexpected ambient color {%.8e, %.8e, %.8e, %.8e}.\n", + U1(U1(material).ambient).r, U2(U1(material).ambient).g, + U3(U1(material).ambient).b, U4(U1(material).ambient).a); + ok(!memcmp(&U2(material).specular, &null_color, sizeof(null_color)), + "Got unexpected specular color {%.8e, %.8e, %.8e, %.8e}.\n", + U1(U2(material).specular).r, U2(U2(material).specular).g, + U3(U2(material).specular).b, U4(U2(material).specular).a); + ok(!memcmp(&U3(material).emissive, &null_color, sizeof(null_color)), + "Got unexpected emissive color {%.8e, %.8e, %.8e, %.8e}.\n", + U1(U3(material).emissive).r, U2(U3(material).emissive).g, + U3(U3(material).emissive).b, U4(U3(material).emissive).a); + ok(U4(material).power == 0.0f, "Got unexpected power %.8e.\n", U4(material).power); + + memset(&material1, 0x11, sizeof(material1)); + memset(&material2, 0x22, sizeof(material2)); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + /* Recorded stateblock. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + /* Predefined stateblock, D3DSBT_ALL. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + /* Predefined stateblock, D3DSBT_VERTEXSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + /* Predefined stateblock, D3DSBT_VERTEXSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetMaterial(device, &material1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetMaterial(device, &material); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n"); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -16521,4 +16702,5 @@ START_TEST(ddraw7) test_begin_end_state_block(); test_transform_state(); test_viewport_state(); + test_material_state(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=51973
Your paranoid android.
=== w8 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w8adm (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w864 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w1064 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/tests/ddraw7.c | 279 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 3dca4dc2da..3867b6992b 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -16555,6 +16555,284 @@ static void test_material_state(void) DestroyWindow(window); }
+#define check_light(a, b, c, d) check_light_(__LINE__, a, b, c, d) +static void check_light_(int line, IDirect3DDevice7 *device, DWORD index, + const D3DLIGHT7 *expected_params, BOOL expected_enabled) +{ + D3DLIGHT7 params; + BOOL enabled; + HRESULT hr; + + hr = IDirect3DDevice7_GetLight(device, index, ¶ms); + if (expected_params) + { + ok_(__FILE__, line)(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + todo_wine_if(memcmp(¶ms, expected_params, sizeof(params))) + ok_(__FILE__, line)(!memcmp(¶ms, expected_params, sizeof(params)), "Light didn't match.\n"); + } + else + { + ok_(__FILE__, line)(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + } + + hr = IDirect3DDevice7_GetLightEnable(device, index, &enabled); + if (expected_params) + { + ok_(__FILE__, line)(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + todo_wine_if(enabled != expected_enabled) + ok_(__FILE__, line)(enabled == expected_enabled, "Got enabled %u, expected %u.\n", enabled, expected_enabled); + } + else + { + ok_(__FILE__, line)(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + } +} + +static void test_light_state(void) +{ + D3DLIGHT7 light1, light2, default_light = {}, empty_light = {}; + IDirect3DDevice7 *device; + DWORD stateblock; + ULONG refcount; + HWND window; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + default_light.dltType = D3DLIGHT_DIRECTIONAL; + U1(default_light.dcvDiffuse).r = 1.0f; + U2(default_light.dcvDiffuse).g = 1.0f; + U3(default_light.dcvDiffuse).b = 1.0f; + default_light.dvDirection.z = 1.0f; + light1 = light2 = default_light; + light1.dltType = D3DLIGHT_POINT; + light2.dltType = D3DLIGHT_SPOT; + + check_light(device, 0, NULL, 0); + + hr = IDirect3DDevice7_SetLight(device, 0, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 0, &light1, 0); + + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 0, &light1, 128); + + hr = IDirect3DDevice7_LightEnable(device, 1, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 1, &default_light, 128); + + hr = IDirect3DDevice7_LightEnable(device, 2, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 2, &default_light, 0); + + hr = IDirect3DDevice7_SetLight(device, 1, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 1, &light1, 128); + + hr = IDirect3DDevice7_SetLight(device, 4, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 4, &light1, 0); + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 3, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 4, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 5, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light1, 128); + check_light(device, 1, &light1, 128); + check_light(device, 2, &default_light, 0); + check_light(device, 3, NULL, 0); + check_light(device, 4, &light1, 0); + check_light(device, 5, NULL, 0); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 0, &light2, 128); + check_light(device, 3, &light2, 0); + check_light(device, 4, &light1, 128); + check_light(device, 5, &default_light, 128); + + hr = IDirect3DDevice7_SetLight(device, 0, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 3, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 3, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 4, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 4, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 5, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 5, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 3, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 3, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 4, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 4, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 5, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 5, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + check_light(device, 0, &light1, 0); + check_light(device, 3, &light1, 0); + check_light(device, 4, &light1, 0); + check_light(device, 5, &light1, 0); + + /* Test trying to capture an unset light. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 6, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 7, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 6, NULL, 0); + check_light(device, 7, NULL, 0); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 6, &empty_light, 0); + check_light(device, 7, &default_light, 0); + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 8, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 8, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light2, 0); + check_light(device, 8, &light2, 128); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 8, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 8, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light1, 0); + check_light(device, 8, &light1, 0); + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_PIXELSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light2, 128); + + hr = IDirect3DDevice7_SetLight(device, 0, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 9, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 9, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light1, 0); + check_light(device, 9, &light2, 128); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetLight(device, 0, &light2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetLight(device, 9, &light1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_LightEnable(device, 9, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + check_light(device, 0, &light1, 0); + check_light(device, 9, &light1, 0); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -16703,4 +16981,5 @@ START_TEST(ddraw7) test_transform_state(); test_viewport_state(); test_material_state(); + test_light_state(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=51974
Your paranoid android.
=== w8 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w8adm (32 bit report) ===
ddraw: ddraw7.c:3826: Test failed: Lit quad with light has color 0x00000000. ddraw7.c:3826: Test failed: Lit quad with singular world matrix has color 0x00000000. ddraw7.c:3826: Test failed: Lit quad with transformation matrix has color 0x00000000. ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w864 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
=== w1064 (32 bit report) ===
ddraw: ddraw7.c:16242: Test failed: Got unexpected viewport. ddraw7.c:16257: Test failed: Got unexpected viewport. ddraw7.c:16264: Test failed: Got unexpected viewport. ddraw7.c:16280: Test failed: Got unexpected viewport. ddraw7.c:16295: Test failed: Got unexpected viewport. ddraw7.c:16311: Test failed: Got unexpected viewport. ddraw7.c:16329: Test failed: Got unexpected viewport. ddraw7.c:16342: Test failed: Got unexpected viewport. ddraw7.c:16357: Test failed: Got unexpected viewport. ddraw7.c:16370: Test failed: Got unexpected viewport.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=51971
Your paranoid android.
=== wvistau64 (64 bit report) ===
ddraw: ddraw7.c:2719: Test failed: Expected message 0x46, but didn't receive it. ddraw7.c:2721: Test failed: Expected screen size 1024x768, got 0x0. ddraw7.c:2727: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2757: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2764: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2790: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2813: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2835: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2861: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2881: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2917: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2927: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2953: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2976: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:2998: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:3024: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:3044: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746). ddraw7.c:3081: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,746).