From 3b2cf06b913fbabc5ab7a8414335b29b4dadc03f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Fri, 27 Feb 2015 10:48:42 +0100 Subject: [PATCH] d3d8/tests: Extend the FPU setup test. --- dlls/d3d8/tests/device.c | 95 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 8 deletions(-) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index e06b1a3ffb5..c8aa72449b0 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -3023,6 +3023,46 @@ static inline WORD get_fpu_cw(void) return cw; } +static WORD callback_cw, callback_set_cw; +static DWORD callback_tid; + +static HRESULT WINAPI dummy_object_QueryInterface(IUnknown *iface, REFIID riid, void **out) +{ + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI dummy_object_AddRef(IUnknown *iface) +{ + callback_cw = get_fpu_cw(); + set_fpu_cw(callback_set_cw); + callback_tid = GetCurrentThreadId(); + return 2; +} + +static ULONG WINAPI dummy_object_Release(IUnknown *iface) +{ + callback_cw = get_fpu_cw(); + set_fpu_cw(callback_set_cw); + callback_tid = GetCurrentThreadId(); + return 1; +} + +static const IUnknownVtbl dummy_object_vtbl = +{ + dummy_object_QueryInterface, + dummy_object_AddRef, + dummy_object_Release, +}; + +static const GUID d3d8_private_data_test_guid = +{ + 0xfdb37466, + 0x428f, + 0x4edf, + {0xa3,0x7f,0x9b,0x1d,0xf4,0x88,0xc5,0xfc} +}; + static void test_fpu_setup(void) { #if defined(D3D8_TEST_SET_FPU_CW) && defined(D3D8_TEST_GET_FPU_CW) @@ -3033,6 +3073,8 @@ static void test_fpu_setup(void) HWND window; HRESULT hr; WORD cw; + IDirect3DSurface8 *surface; + IUnknown dummy_object = {&dummy_object_vtbl}; window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_CAPTION, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, 0, 0, 0, 0); @@ -3062,7 +3104,34 @@ static void test_fpu_setup(void) cw = get_fpu_cw(); ok(cw == 0x7f, "cw is %#x, expected 0x7f.\n", cw); + hr = IDirect3DDevice8_GetRenderTarget(device, &surface); + ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr); + + callback_set_cw = 0xf60; + hr = IDirect3DSurface8_SetPrivateData(surface, &d3d8_private_data_test_guid, + &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN); + ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr); + ok(callback_cw == 0x7f, "Callback cw is %#x, expected 0x7f.\n", callback_cw); + ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n"); + cw = get_fpu_cw(); + ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw); + + callback_cw = 0; + hr = IDirect3DSurface8_SetPrivateData(surface, &d3d8_private_data_test_guid, + &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN); + ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr); + ok(callback_cw == 0xf60, "Callback cw is %#x, expected 0xf60.\n", callback_cw); + ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n"); + + callback_set_cw = 0x7f; + set_fpu_cw(0x7f); + + IDirect3DSurface8_Release(surface); + + callback_cw = 0; IDirect3DDevice8_Release(device); + ok(callback_cw == 0x7f, "Callback cw is %#x, expected 0x7f.\n", callback_cw); + ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n"); cw = get_fpu_cw(); ok(cw == 0x7f, "cw is %#x, expected 0x7f.\n", cw); @@ -3076,9 +3145,26 @@ static void test_fpu_setup(void) cw = get_fpu_cw(); ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw); - set_fpu_cw(0x37f); + hr = IDirect3DDevice8_GetRenderTarget(device, &surface); + ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr); + + callback_cw = 0; + callback_set_cw = 0x37f; + hr = IDirect3DSurface8_SetPrivateData(surface, &d3d8_private_data_test_guid, + &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN); + ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr); + ok(callback_cw == 0xf60, "Callback cw is %#x, expected 0xf60.\n", callback_cw); + ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n"); + cw = get_fpu_cw(); + ok(cw == 0x37f, "cw is %#x, expected 0x37f.\n", cw); + + IDirect3DSurface8_Release(surface); + + callback_cw = 0; IDirect3DDevice8_Release(device); + ok(callback_cw == 0x37f, "Callback cw is %#x, expected 0x37f.\n", callback_cw); + ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n"); done: DestroyWindow(window); @@ -4541,13 +4627,6 @@ static void test_private_data(void) HRESULT hr; DWORD size; DWORD data[4] = {1, 2, 3, 4}; - static const GUID d3d8_private_data_test_guid = - { - 0xfdb37466, - 0x428f, - 0x4edf, - {0xa3,0x7f,0x9b,0x1d,0xf4,0x88,0xc5,0xfc} - }; static const GUID d3d8_private_data_test_guid2 = { 0x2e5afac2, -- 2.11.4.GIT