d3d8/tests: Check if the current display settings match the registry settings.

This commit is contained in:
Stefan Dösinger 2014-11-03 22:34:00 +01:00 committed by Alexandre Julliard
parent 40c2fc215d
commit dcf7d294cc
1 changed files with 53 additions and 38 deletions

View File

@ -46,8 +46,7 @@ struct device_desc
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
static INT screen_width;
static INT screen_height;
static DEVMODEW registry_mode;
static HRESULT (WINAPI *ValidateVertexShader)(DWORD *, DWORD *, DWORD *, int, DWORD *);
static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, int, DWORD *);
@ -144,8 +143,8 @@ static HRESULT reset_device(IDirect3DDevice8 *device, HWND device_window, BOOL w
present_parameters.Windowed = windowed;
present_parameters.hDeviceWindow = device_window;
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferWidth = screen_width;
present_parameters.BackBufferHeight = screen_height;
present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
present_parameters.BackBufferHeight = registry_mode.dmPelsHeight;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
@ -2182,7 +2181,8 @@ static DWORD WINAPI wndproc_thread(void *param)
BOOL ret;
p->dummy_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, screen_width, screen_height, 0, 0, 0, 0);
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
registry_mode.dmPelsHeight, 0, 0, 0, 0);
p->running_in_foreground = SetForegroundWindow(p->dummy_window);
ret = SetEvent(p->window_created);
@ -2244,9 +2244,11 @@ static void test_wndproc(void)
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, screen_width, screen_height, 0, 0, 0, 0);
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, registry_mode.dmPelsWidth,
registry_mode.dmPelsHeight, 0, 0, 0, 0);
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, screen_width, screen_height, 0, 0, 0, 0);
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, registry_mode.dmPelsWidth,
registry_mode.dmPelsHeight, 0, 0, 0, 0);
thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
@ -2279,8 +2281,8 @@ static void test_wndproc(void)
expect_messages = messages;
device_desc.device_window = device_window;
device_desc.width = screen_width;
device_desc.height = screen_height;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
@ -2389,9 +2391,11 @@ static void test_wndproc_windowed(void)
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, screen_width, screen_height, 0, 0, 0, 0);
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
registry_mode.dmPelsHeight, 0, 0, 0, 0);
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, screen_width, screen_height, 0, 0, 0, 0);
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
registry_mode.dmPelsHeight, 0, 0, 0, 0);
thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
@ -2600,7 +2604,8 @@ static void test_fpu_setup(void)
HRESULT hr;
WORD cw;
window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_CAPTION, 0, 0, screen_width, screen_height, 0, 0, 0, 0);
window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_CAPTION, 0, 0,
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, 0, 0, 0, 0);
ok(!!window, "Failed to create a window.\n");
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d8, "Failed to create a D3D object.\n");
@ -2779,9 +2784,9 @@ static void test_window_style(void)
ULONG ref;
focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
device_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d8, "Failed to create a D3D object.\n");
@ -2790,12 +2795,12 @@ static void test_window_style(void)
focus_style = GetWindowLongA(focus_window, GWL_STYLE);
focus_exstyle = GetWindowLongA(focus_window, GWL_EXSTYLE);
SetRect(&fullscreen_rect, 0, 0, screen_width, screen_height);
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
GetWindowRect(focus_window, &focus_rect);
device_desc.device_window = device_window;
device_desc.width = screen_width;
device_desc.height = screen_height;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
@ -2989,18 +2994,18 @@ static void test_mode_change(void)
DWORD ret;
focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
device_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d8, "Failed to create a D3D object.\n");
SetRect(&fullscreen_rect, 0, 0, screen_width, screen_height);
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
GetWindowRect(focus_window, &focus_rect);
device_desc.device_window = device_window;
device_desc.width = screen_width;
device_desc.height = screen_height;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
@ -3037,8 +3042,8 @@ static void test_mode_change(void)
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface8_GetDesc(backbuffer, &desc);
ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#x.\n", hr);
ok(desc.Width == screen_width, "Got unexpected backbuffer width %u.\n", desc.Width);
ok(desc.Height == screen_height, "Got unexpected backbuffer height %u.\n", desc.Height);
ok(desc.Width == registry_mode.dmPelsWidth, "Got unexpected backbuffer width %u.\n", desc.Width);
ok(desc.Height == registry_mode.dmPelsHeight, "Got unexpected backbuffer height %u.\n", desc.Height);
IDirect3DSurface8_Release(backbuffer);
refcount = IDirect3DDevice8_Release(device);
@ -3048,8 +3053,8 @@ static void test_mode_change(void)
devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
ok(devmode.dmPelsWidth == screen_width, "Got unexpect width %u.\n", devmode.dmPelsWidth);
ok(devmode.dmPelsHeight == screen_height, "Got unexpect height %u.\n", devmode.dmPelsHeight);
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
done:
DestroyWindow(device_window);
@ -3060,8 +3065,8 @@ done:
devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
ok(devmode.dmPelsWidth == screen_width, "Got unexpect width %u.\n", devmode.dmPelsWidth);
ok(devmode.dmPelsHeight == screen_height, "Got unexpect height %u.\n", devmode.dmPelsHeight);
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
}
static void test_device_window_reset(void)
@ -3080,13 +3085,13 @@ static void test_device_window_reset(void)
ok(RegisterClassA(&wc), "Failed to register window class.\n");
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, screen_width / 2, screen_height / 2, 0, 0, 0, 0);
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d8, "Failed to create a D3D object.\n");
SetRect(&fullscreen_rect, 0, 0, screen_width, screen_height);
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
GetWindowRect(device_window, &device_rect);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@ -3097,8 +3102,8 @@ static void test_device_window_reset(void)
(LONG_PTR)test_proc, proc);
device_desc.device_window = NULL;
device_desc.width = screen_width;
device_desc.height = screen_height;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
@ -6388,8 +6393,8 @@ static void test_lost_device(void)
d3d = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
device_desc.device_window = window;
device_desc.width = screen_width;
device_desc.height = screen_height;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d, window, &device_desc)))
{
@ -6560,6 +6565,7 @@ START_TEST(device)
HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
WNDCLASSA wc = {0};
IDirect3D8 *d3d8;
DEVMODEW current_mode;
if (!d3d8_handle)
{
@ -6567,6 +6573,18 @@ START_TEST(device)
return;
}
memset(&current_mode, 0, sizeof(current_mode));
current_mode.dmSize = sizeof(current_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &current_mode), "Failed to get display mode.\n");
registry_mode.dmSize = sizeof(registry_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &registry_mode), "Failed to get display mode.\n");
if (current_mode.dmPelsWidth != registry_mode.dmPelsWidth
|| current_mode.dmPelsHeight != registry_mode.dmPelsHeight)
{
skip("Current mode does not match registry mode, skipping test.\n");
return;
}
wc.lpfnWndProc = DefWindowProcA;
wc.lpszClassName = "d3d8_test_wc";
RegisterClassA(&wc);
@ -6581,9 +6599,6 @@ START_TEST(device)
}
IDirect3D8_Release(d3d8);
screen_width = GetSystemMetrics(SM_CXSCREEN);
screen_height = GetSystemMetrics(SM_CYSCREEN);
test_fpu_setup();
test_display_formats();
test_display_modes();