From: Stefan Dösinger Subject: [PATCH 2/6] d3d9/tests: Use create_device in test_fpu_setup. Message-Id: <1413803335-25557-2-git-send-email-stefan@codeweavers.com> Date: Mon, 20 Oct 2014 13:08:51 +0200 --- dlls/d3d9/tests/device.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index a86582b..5a55fcb 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -33,6 +33,8 @@ struct vec3 #define CREATE_DEVICE_FULLSCREEN 0x01 #define CREATE_DEVICE_NOWINDOWCHANGES 0x02 +#define CREATE_DEVICE_FPU_PRESERVE 0x04 +#define CREATE_DEVICE_HWVP_ONLY 0x08 struct device_desc { @@ -151,6 +153,8 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window, cons present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN); if (desc->flags & CREATE_DEVICE_NOWINDOWCHANGES) behavior_flags |= D3DCREATE_NOWINDOWCHANGES; + if (desc->flags & CREATE_DEVICE_FPU_PRESERVE) + behavior_flags |= D3DCREATE_FPU_PRESERVE; } if (SUCCEEDED(IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window, @@ -162,6 +166,9 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window, cons behavior_flags, &present_parameters, &device))) return device; + if (desc && desc->flags & CREATE_DEVICE_HWVP_ONLY) + return NULL; + behavior_flags ^= (D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_SOFTWARE_VERTEXPROCESSING); if (SUCCEEDED(IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window, @@ -3586,11 +3593,10 @@ static inline WORD get_fpu_cw(void) static void test_fpu_setup(void) { #if defined(D3D9_TEST_SET_FPU_CW) && defined(D3D9_TEST_GET_FPU_CW) - D3DPRESENT_PARAMETERS present_parameters; + struct device_desc device_desc; IDirect3DDevice9 *device; HWND window = NULL; IDirect3D9 *d3d9; - HRESULT hr; WORD cw; window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_CAPTION, 0, 0, screen_width, screen_height, 0, 0, 0, 0); @@ -3598,20 +3604,18 @@ static void test_fpu_setup(void) d3d9 = Direct3DCreate9(D3D_SDK_VERSION); ok(!!d3d9, "Failed to create a D3D object.\n"); - memset(&present_parameters, 0, sizeof(present_parameters)); - present_parameters.Windowed = TRUE; - present_parameters.hDeviceWindow = window; - present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + device_desc.device_window = window; + device_desc.width = 640; + device_desc.height = 480; + device_desc.flags = CREATE_DEVICE_HWVP_ONLY; set_fpu_cw(0xf60); cw = get_fpu_cw(); ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw); - hr = IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, - D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device); - if (FAILED(hr)) + if (!(device = create_device(d3d9, window, &device_desc))) { - skip("Failed to create a device, hr %#x.\n", hr); + skip("Failed to create a 3D device, skipping test.\n"); set_fpu_cw(0x37f); goto done; } @@ -3627,9 +3631,9 @@ static void test_fpu_setup(void) cw = get_fpu_cw(); ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw); - hr = IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, - D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &present_parameters, &device); - ok(SUCCEEDED(hr), "CreateDevice failed, hr %#x.\n", hr); + device_desc.flags = CREATE_DEVICE_HWVP_ONLY | CREATE_DEVICE_FPU_PRESERVE; + device = create_device(d3d9, window, &device_desc); + ok(device != NULL, "CreateDevice failed.\n"); cw = get_fpu_cw(); ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw); -- 2.0.4