d3d9/tests: Test display mode restoration.
Mostly to test that when doing mode restoration, all display outputs get restored to their display settings in the registry, not just one output gets restored. Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e166f6d07e
commit
df90c0ef7e
|
@ -25,6 +25,7 @@
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "wine/heap.h"
|
||||||
|
|
||||||
struct vec3
|
struct vec3
|
||||||
{
|
{
|
||||||
|
@ -158,6 +159,77 @@ static BOOL adapter_is_warp(const D3DADAPTER_IDENTIFIER9 *identifier)
|
||||||
return !strcmp(identifier->Driver, "d3d10warp.dll");
|
return !strcmp(identifier->Driver, "d3d10warp.dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL equal_mode_rect(const DEVMODEW *mode1, const DEVMODEW *mode2)
|
||||||
|
{
|
||||||
|
return mode1->dmPosition.x == mode2->dmPosition.x
|
||||||
|
&& mode1->dmPosition.y == mode2->dmPosition.y
|
||||||
|
&& mode1->dmPelsWidth == mode2->dmPelsWidth
|
||||||
|
&& mode1->dmPelsHeight == mode2->dmPelsHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free original_modes after finished using it */
|
||||||
|
static BOOL save_display_modes(DEVMODEW **original_modes, unsigned int *display_count)
|
||||||
|
{
|
||||||
|
unsigned int number, size = 2, count = 0, index = 0;
|
||||||
|
DISPLAY_DEVICEW display_device;
|
||||||
|
DEVMODEW *modes, *tmp;
|
||||||
|
|
||||||
|
if (!(modes = heap_alloc(size * sizeof(*modes))))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
display_device.cb = sizeof(display_device);
|
||||||
|
while (EnumDisplayDevicesW(NULL, index++, &display_device, 0))
|
||||||
|
{
|
||||||
|
/* Skip software devices */
|
||||||
|
if (swscanf(display_device.DeviceName, L"\\\\.\\DISPLAY%u", &number) != 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!(display_device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (count >= size)
|
||||||
|
{
|
||||||
|
size *= 2;
|
||||||
|
if (!(tmp = heap_realloc(modes, size * sizeof(*modes))))
|
||||||
|
{
|
||||||
|
heap_free(modes);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
modes = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&modes[count], 0, sizeof(modes[count]));
|
||||||
|
modes[count].dmSize = sizeof(modes[count]);
|
||||||
|
if (!EnumDisplaySettingsW(display_device.DeviceName, ENUM_CURRENT_SETTINGS, &modes[count]))
|
||||||
|
{
|
||||||
|
heap_free(modes);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
lstrcpyW(modes[count++].dmDeviceName, display_device.DeviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
*original_modes = modes;
|
||||||
|
*display_count = count;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL restore_display_modes(DEVMODEW *modes, unsigned int count)
|
||||||
|
{
|
||||||
|
unsigned int index;
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
for (index = 0; index < count; ++index)
|
||||||
|
{
|
||||||
|
ret = ChangeDisplaySettingsExW(modes[index].dmDeviceName, &modes[index], NULL,
|
||||||
|
CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
|
||||||
|
if (ret != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ret = ChangeDisplaySettingsExW(NULL, NULL, NULL, 0, NULL);
|
||||||
|
return ret == DISP_CHANGE_SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window, const struct device_desc *desc)
|
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window, const struct device_desc *desc)
|
||||||
{
|
{
|
||||||
D3DPRESENT_PARAMETERS present_parameters = {0};
|
D3DPRESENT_PARAMETERS present_parameters = {0};
|
||||||
|
@ -5198,21 +5270,34 @@ done:
|
||||||
|
|
||||||
static void test_mode_change(void)
|
static void test_mode_change(void)
|
||||||
{
|
{
|
||||||
|
DEVMODEW old_devmode, devmode, devmode2, *original_modes = NULL;
|
||||||
|
struct device_desc device_desc, device_desc2;
|
||||||
|
WCHAR second_monitor_name[CCHDEVICENAME];
|
||||||
|
IDirect3DDevice9 *device, *device2;
|
||||||
|
unsigned int display_count = 0;
|
||||||
RECT d3d_rect, focus_rect, r;
|
RECT d3d_rect, focus_rect, r;
|
||||||
struct device_desc device_desc;
|
|
||||||
IDirect3DSurface9 *backbuffer;
|
IDirect3DSurface9 *backbuffer;
|
||||||
IDirect3DDevice9 *device;
|
MONITORINFOEXW monitor_info;
|
||||||
|
HMONITOR second_monitor;
|
||||||
D3DSURFACE_DESC desc;
|
D3DSURFACE_DESC desc;
|
||||||
IDirect3D9 *d3d9;
|
IDirect3D9 *d3d9;
|
||||||
DEVMODEW devmode;
|
|
||||||
ULONG refcount;
|
ULONG refcount;
|
||||||
UINT adapter_mode_count, i;
|
UINT adapter_mode_count, i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DWORD ret;
|
BOOL ret;
|
||||||
LONG change_ret;
|
LONG change_ret;
|
||||||
D3DDISPLAYMODE d3ddm;
|
D3DDISPLAYMODE d3ddm;
|
||||||
DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
|
DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
|
||||||
|
|
||||||
|
memset(&devmode, 0, sizeof(devmode));
|
||||||
|
devmode.dmSize = sizeof(devmode);
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode, ®istry_mode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode, ®istry_mode), "Got a different mode.\n");
|
||||||
|
|
||||||
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
|
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
ok(!!d3d9, "Failed to create a D3D object.\n");
|
ok(!!d3d9, "Failed to create a D3D object.\n");
|
||||||
|
|
||||||
|
@ -5265,6 +5350,9 @@ static void test_mode_change(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = save_display_modes(&original_modes, &display_count);
|
||||||
|
ok(ret, "Failed to save original display modes.\n");
|
||||||
|
|
||||||
memset(&devmode, 0, sizeof(devmode));
|
memset(&devmode, 0, sizeof(devmode));
|
||||||
devmode.dmSize = sizeof(devmode);
|
devmode.dmSize = sizeof(devmode);
|
||||||
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
|
@ -5289,8 +5377,6 @@ static void test_mode_change(void)
|
||||||
if (!(device = create_device(d3d9, focus_window, &device_desc)))
|
if (!(device = create_device(d3d9, focus_window, &device_desc)))
|
||||||
{
|
{
|
||||||
skip("Failed to create a D3D device, skipping tests.\n");
|
skip("Failed to create a D3D device, skipping tests.\n");
|
||||||
change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
|
|
||||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5344,6 +5430,7 @@ static void test_mode_change(void)
|
||||||
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
ok(!!(device = create_device(d3d9, focus_window, &device_desc)), "Failed to create a D3D device.\n");
|
ok(!!(device = create_device(d3d9, focus_window, &device_desc)), "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
devmode.dmPelsWidth = user32_width;
|
devmode.dmPelsWidth = user32_width;
|
||||||
devmode.dmPelsHeight = user32_height;
|
devmode.dmPelsHeight = user32_height;
|
||||||
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
||||||
|
@ -5352,17 +5439,319 @@ static void test_mode_change(void)
|
||||||
refcount = IDirect3DDevice9_Release(device);
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
memset(&devmode2, 0, sizeof(devmode2));
|
||||||
|
devmode2.dmSize = sizeof(devmode2);
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
ok(ret, "Failed to get display mode.\n");
|
ok(ret, "Failed to get display mode.\n");
|
||||||
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
|
ok(devmode2.dmPelsWidth == registry_mode.dmPelsWidth
|
||||||
&& devmode.dmPelsHeight == registry_mode.dmPelsHeight,
|
&& devmode2.dmPelsHeight == registry_mode.dmPelsHeight,
|
||||||
"Expected resolution %ux%u, got %ux%u.\n",
|
"Expected resolution %ux%u, got %ux%u.\n", registry_mode.dmPelsWidth,
|
||||||
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
|
registry_mode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test that no mode restorations if no mode changes happened */
|
||||||
|
change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
|
||||||
|
device_desc.device_window = device_window;
|
||||||
|
device_desc.width = d3d_width;
|
||||||
|
device_desc.height = d3d_height;
|
||||||
|
device_desc.flags = 0;
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, ®istry_mode), "Got a different mode.\n");
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test that mode restorations use display settings in the registry with a fullscreen device */
|
||||||
|
change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
|
||||||
|
device_desc.device_window = device_window;
|
||||||
|
device_desc.width = registry_mode.dmPelsWidth;
|
||||||
|
device_desc.height = registry_mode.dmPelsHeight;
|
||||||
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test that mode restorations use display settings in the registry with a fullscreen device
|
||||||
|
* having the same display mode and then reset to a different mode */
|
||||||
|
change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
|
||||||
|
device_desc.device_window = device_window;
|
||||||
|
device_desc.width = registry_mode.dmPelsWidth;
|
||||||
|
device_desc.height = registry_mode.dmPelsHeight;
|
||||||
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
device_desc.width = d3d_width;
|
||||||
|
device_desc.height = d3d_height;
|
||||||
|
hr = reset_device(device, &device_desc);
|
||||||
|
ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(devmode2.dmPelsWidth == d3d_width && devmode2.dmPelsHeight == d3d_height,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", d3d_width, d3d_height,
|
||||||
|
devmode2.dmPelsWidth, devmode2.dmPelsHeight);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
if (IDirect3D9_GetAdapterCount(d3d9) < 2)
|
||||||
|
{
|
||||||
|
skip("Following tests require two adapters.\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
second_monitor = IDirect3D9_GetAdapterMonitor(d3d9, 1);
|
||||||
|
monitor_info.cbSize = sizeof(monitor_info);
|
||||||
|
ret = GetMonitorInfoW(second_monitor, (MONITORINFO *)&monitor_info);
|
||||||
|
ok(ret, "GetMonitorInfoW failed, error %#x.\n", GetLastError());
|
||||||
|
lstrcpyW(second_monitor_name, monitor_info.szDevice);
|
||||||
|
|
||||||
|
memset(&old_devmode, 0, sizeof(old_devmode));
|
||||||
|
old_devmode.dmSize = sizeof(old_devmode);
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
d3d_width = 0;
|
||||||
|
d3d_height = 0;
|
||||||
|
user32_width = 0;
|
||||||
|
user32_height = 0;
|
||||||
|
while (EnumDisplaySettingsW(second_monitor_name, i++, &devmode))
|
||||||
|
{
|
||||||
|
if (devmode.dmPelsWidth == old_devmode.dmPelsWidth
|
||||||
|
&& devmode.dmPelsHeight == old_devmode.dmPelsHeight)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!d3d_width && !d3d_height)
|
||||||
|
{
|
||||||
|
d3d_width = devmode.dmPelsWidth;
|
||||||
|
d3d_height = devmode.dmPelsHeight;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devmode.dmPelsWidth == d3d_width && devmode.dmPelsHeight == d3d_height)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
user32_width = devmode.dmPelsWidth;
|
||||||
|
user32_height = devmode.dmPelsHeight;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!user32_width || !user32_height)
|
||||||
|
{
|
||||||
|
skip("Failed to find three different display modes for the second monitor.\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test that mode restorations also happen for non-primary monitors on device resets */
|
||||||
|
device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
|
||||||
|
device_desc.device_window = device_window;
|
||||||
|
device_desc.width = registry_mode.dmPelsWidth;
|
||||||
|
device_desc.height = registry_mode.dmPelsHeight;
|
||||||
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
if (devmode2.dmPelsWidth == old_devmode.dmPelsWidth
|
||||||
|
&& devmode2.dmPelsHeight == old_devmode.dmPelsHeight)
|
||||||
|
{
|
||||||
|
skip("Failed to change display settings of the second monitor.\n");
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
device_desc.flags = 0;
|
||||||
|
hr = reset_device(device, &device_desc);
|
||||||
|
ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
|
||||||
|
ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||||
|
todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n",
|
||||||
|
old_devmode.dmPelsWidth, d3ddm.Width);
|
||||||
|
todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n",
|
||||||
|
old_devmode.dmPelsHeight, d3ddm.Height);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test that mode restorations happen for non-primary monitors on device releases */
|
||||||
|
device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
|
||||||
|
device_desc.device_window = device_window;
|
||||||
|
device_desc.width = registry_mode.dmPelsWidth;
|
||||||
|
device_desc.height = registry_mode.dmPelsHeight;
|
||||||
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
|
||||||
|
ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||||
|
todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n",
|
||||||
|
old_devmode.dmPelsWidth, d3ddm.Width);
|
||||||
|
todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n",
|
||||||
|
old_devmode.dmPelsHeight, d3ddm.Height);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test that mode restorations for non-primary monitors use display settings in the registry */
|
||||||
|
device = create_device(d3d9, device_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
|
||||||
|
CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
|
||||||
|
devmode2.dmPelsWidth, devmode2.dmPelsHeight);
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
|
||||||
|
devmode2.dmPelsWidth, devmode2.dmPelsHeight);
|
||||||
|
hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
|
||||||
|
ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||||
|
todo_wine ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
|
||||||
|
d3ddm.Width, d3ddm.Height);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test mode restorations when there are two fullscreen devices and one of them got reset */
|
||||||
|
device = create_device(d3d9, focus_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
device_desc2.adapter_ordinal = 1;
|
||||||
|
device_desc2.device_window = device_window;
|
||||||
|
device_desc2.width = d3d_width;
|
||||||
|
device_desc2.height = d3d_height;
|
||||||
|
device_desc2.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device2 = create_device(d3d9, focus_window, &device_desc2);
|
||||||
|
ok(!!device2, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
device_desc.flags = 0;
|
||||||
|
hr = reset_device(device, &device_desc);
|
||||||
|
ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
|
||||||
|
ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||||
|
todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth,
|
||||||
|
old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device2);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
|
||||||
|
/* Test mode restoration when there are two fullscreen devices and one of them got released */
|
||||||
|
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||||
|
device = create_device(d3d9, focus_window, &device_desc);
|
||||||
|
ok(!!device, "Failed to create a D3D device.\n");
|
||||||
|
device2 = create_device(d3d9, focus_window, &device_desc2);
|
||||||
|
ok(!!device2, "Failed to create a D3D device.\n");
|
||||||
|
|
||||||
|
change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
|
||||||
|
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
|
||||||
|
ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
|
||||||
|
ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
|
||||||
|
hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
|
||||||
|
ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||||
|
todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight,
|
||||||
|
"Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth,
|
||||||
|
old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice9_Release(device2);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
DestroyWindow(device_window);
|
DestroyWindow(device_window);
|
||||||
DestroyWindow(focus_window);
|
DestroyWindow(focus_window);
|
||||||
IDirect3D9_Release(d3d9);
|
IDirect3D9_Release(d3d9);
|
||||||
|
ret = restore_display_modes(original_modes, display_count);
|
||||||
|
ok(ret, "Failed to restore display modes.\n");
|
||||||
|
heap_free(original_modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_device_window_reset(void)
|
static void test_device_window_reset(void)
|
||||||
|
|
Loading…
Reference in New Issue