wined3d: Implement mode setting in the adapter instead of the device.
This commit is contained in:
parent
1c2f9255f4
commit
0f0fe49240
|
@ -1076,7 +1076,7 @@ static HRESULT ddraw_set_display_mode(struct ddraw *ddraw, DWORD Width, DWORD He
|
|||
*/
|
||||
|
||||
/* TODO: Lose the primary surface */
|
||||
hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &mode);
|
||||
hr = wined3d_set_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode);
|
||||
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
|
|
@ -1562,79 +1562,6 @@ void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device)
|
|||
device->create_parms.flags |= WINED3DCREATE_MULTITHREADED;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_device_set_display_mode(struct wined3d_device *device,
|
||||
UINT swapchain_idx, const struct wined3d_display_mode *mode)
|
||||
{
|
||||
struct wined3d_adapter *adapter = device->adapter;
|
||||
const struct wined3d_format *format = wined3d_get_format(&adapter->gl_info, mode->format_id);
|
||||
struct wined3d_display_mode current_mode;
|
||||
DEVMODEW devmode;
|
||||
LONG ret;
|
||||
RECT clip_rc;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("device %p, swapchain_idx %u, mode %p (%ux%u@%u %s).\n", device, swapchain_idx, mode,
|
||||
mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id));
|
||||
|
||||
/* Resize the screen even without a window:
|
||||
* The app could have unset it with SetCooperativeLevel, but not called
|
||||
* RestoreDisplayMode first. Then the release will call RestoreDisplayMode,
|
||||
* but we don't have any hwnd
|
||||
*/
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
|
||||
devmode.dmPelsWidth = mode->width;
|
||||
devmode.dmPelsHeight = mode->height;
|
||||
|
||||
devmode.dmDisplayFrequency = mode->refresh_rate;
|
||||
if (mode->refresh_rate)
|
||||
devmode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
|
||||
/* Only change the mode if necessary */
|
||||
if (FAILED(hr = wined3d_device_get_display_mode(device, swapchain_idx, ¤t_mode)))
|
||||
{
|
||||
ERR("Failed to get current display mode, hr %#x.\n", hr);
|
||||
}
|
||||
else if (current_mode.width == mode->width
|
||||
&& current_mode.height == mode->height
|
||||
&& current_mode.format_id == mode->format_id
|
||||
&& (current_mode.refresh_rate == mode->refresh_rate
|
||||
|| !mode->refresh_rate))
|
||||
{
|
||||
TRACE("Skipping redundant mode setting call.\n");
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL);
|
||||
if (ret != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
if (devmode.dmDisplayFrequency)
|
||||
{
|
||||
WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate\n");
|
||||
devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
|
||||
devmode.dmDisplayFrequency = 0;
|
||||
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL;
|
||||
}
|
||||
if(ret != DISP_CHANGE_SUCCESSFUL) {
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Store the new values */
|
||||
adapter->screen_size.cx = mode->width;
|
||||
adapter->screen_size.cy = mode->height;
|
||||
adapter->screen_format = mode->format_id;
|
||||
|
||||
/* And finally clip mouse to our screen */
|
||||
SetRect(&clip_rc, 0, 0, mode->width, mode->height);
|
||||
ClipCursor(&clip_rc);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_device_get_wined3d(const struct wined3d_device *device, struct wined3d **wined3d)
|
||||
{
|
||||
TRACE("device %p, wined3d %p.\n", device, wined3d);
|
||||
|
@ -5476,7 +5403,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
if (!swapchain_desc->windowed != !swapchain->desc.windowed
|
||||
|| DisplayModeChanged)
|
||||
{
|
||||
wined3d_device_set_display_mode(device, 0, &mode);
|
||||
if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, &mode)))
|
||||
{
|
||||
WARN("Failed to set display mode, hr %#x.\n", hr);
|
||||
wined3d_swapchain_decref(swapchain);
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (!swapchain_desc->windowed)
|
||||
{
|
||||
|
|
|
@ -3075,6 +3075,78 @@ HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UI
|
|||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
|
||||
UINT adapter_idx, const struct wined3d_display_mode *mode)
|
||||
{
|
||||
struct wined3d_display_mode current_mode;
|
||||
const struct wined3d_format *format;
|
||||
struct wined3d_adapter *adapter;
|
||||
DEVMODEW devmode;
|
||||
RECT clip_rc;
|
||||
HRESULT hr;
|
||||
LONG ret;
|
||||
|
||||
TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s).\n", wined3d, adapter_idx, mode,
|
||||
mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id));
|
||||
|
||||
if (adapter_idx >= wined3d->adapter_count)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
adapter = &wined3d->adapters[adapter_idx];
|
||||
format = wined3d_get_format(&adapter->gl_info, mode->format_id);
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
|
||||
devmode.dmPelsWidth = mode->width;
|
||||
devmode.dmPelsHeight = mode->height;
|
||||
|
||||
devmode.dmDisplayFrequency = mode->refresh_rate;
|
||||
if (mode->refresh_rate)
|
||||
devmode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
|
||||
/* Only change the mode if necessary. */
|
||||
if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, ¤t_mode)))
|
||||
{
|
||||
ERR("Failed to get current display mode, hr %#x.\n", hr);
|
||||
}
|
||||
else if (current_mode.width == mode->width
|
||||
&& current_mode.height == mode->height
|
||||
&& current_mode.format_id == mode->format_id
|
||||
&& (current_mode.refresh_rate == mode->refresh_rate
|
||||
|| !mode->refresh_rate))
|
||||
{
|
||||
TRACE("Skipping redundant mode setting call.\n");
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL);
|
||||
if (ret != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
if (devmode.dmDisplayFrequency)
|
||||
{
|
||||
WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
|
||||
devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
|
||||
devmode.dmDisplayFrequency = 0;
|
||||
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL);
|
||||
}
|
||||
if (ret != DISP_CHANGE_SUCCESSFUL)
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
|
||||
/* Store the new values. */
|
||||
adapter->screen_size.cx = mode->width;
|
||||
adapter->screen_size.cy = mode->height;
|
||||
adapter->screen_format = mode->format_id;
|
||||
|
||||
/* And finally clip mouse to our screen. */
|
||||
SetRect(&clip_rc, 0, 0, mode->width, mode->height);
|
||||
ClipCursor(&clip_rc);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
|
||||
and fields being inserted in the middle, a new structure is used in place */
|
||||
HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
|
||||
|
|
|
@ -31,6 +31,7 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
|
|||
static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
|
||||
{
|
||||
struct wined3d_display_mode mode;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
||||
TRACE("Destroying swapchain %p.\n", swapchain);
|
||||
|
@ -79,7 +80,9 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
|
|||
mode.height = swapchain->orig_height;
|
||||
mode.refresh_rate = 0;
|
||||
mode.format_id = swapchain->orig_fmt;
|
||||
wined3d_device_set_display_mode(swapchain->device, 0, &mode);
|
||||
if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d,
|
||||
swapchain->device->adapter->ordinal, &mode)))
|
||||
ERR("Failed to restore display mode, hr %#x.\n", hr);
|
||||
}
|
||||
|
||||
if (swapchain->backup_dc)
|
||||
|
@ -964,8 +967,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, enum wined3d_
|
|||
mode.format_id = desc->backbuffer_format;
|
||||
mode.refresh_rate = desc->refresh_rate;
|
||||
|
||||
hr = wined3d_device_set_display_mode(device, 0, &mode);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, &mode)))
|
||||
{
|
||||
WARN("Failed to set display mode, hr %#x.\n", hr);
|
||||
goto err;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
@ cdecl wined3d_get_device_caps(ptr long long ptr)
|
||||
@ cdecl wined3d_incref(ptr)
|
||||
@ cdecl wined3d_register_software_device(ptr ptr)
|
||||
@ cdecl wined3d_set_adapter_display_mode(ptr long ptr)
|
||||
|
||||
@ cdecl wined3d_buffer_create(ptr ptr ptr ptr ptr ptr)
|
||||
@ cdecl wined3d_buffer_create_ib(ptr long long long ptr ptr ptr)
|
||||
|
@ -109,7 +110,6 @@
|
|||
@ cdecl wined3d_device_set_cursor_properties(ptr long long ptr)
|
||||
@ cdecl wined3d_device_set_depth_stencil(ptr ptr)
|
||||
@ cdecl wined3d_device_set_dialog_box_mode(ptr long)
|
||||
@ cdecl wined3d_device_set_display_mode(ptr long ptr)
|
||||
@ cdecl wined3d_device_set_gamma_ramp(ptr long long ptr)
|
||||
@ cdecl wined3d_device_set_index_buffer(ptr ptr long)
|
||||
@ cdecl wined3d_device_set_light(ptr long ptr)
|
||||
|
|
|
@ -2033,6 +2033,8 @@ HRESULT __cdecl wined3d_get_device_caps(const struct wined3d *wined3d, UINT adap
|
|||
enum wined3d_device_type device_type, WINED3DCAPS *caps);
|
||||
ULONG __cdecl wined3d_incref(struct wined3d *wined3d);
|
||||
HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void *init_function);
|
||||
HRESULT __cdecl wined3d_set_adapter_display_mode(struct wined3d *wined3d,
|
||||
UINT adapter_idx, const struct wined3d_display_mode *mode);
|
||||
|
||||
HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc,
|
||||
const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
|
||||
|
@ -2181,8 +2183,6 @@ HRESULT __cdecl wined3d_device_set_cursor_properties(struct wined3d_device *devi
|
|||
UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_surface);
|
||||
HRESULT __cdecl wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil);
|
||||
HRESULT __cdecl wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs);
|
||||
HRESULT __cdecl wined3d_device_set_display_mode(struct wined3d_device *device,
|
||||
UINT swapchain_idx, const struct wined3d_display_mode *mode);
|
||||
void __cdecl wined3d_device_set_gamma_ramp(const struct wined3d_device *device,
|
||||
UINT swapchain_idx, DWORD flags, const struct wined3d_gamma_ramp *ramp);
|
||||
HRESULT __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device,
|
||||
|
|
Loading…
Reference in New Issue