From 73eceafb17b66e957ffedb338513949e78806133 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Sun, 8 Jul 2012 16:06:37 +0200 Subject: [PATCH] d3d9: Implement d3d9_device_ResetEx(). --- dlls/d3d8/device.c | 2 +- dlls/d3d9/device.c | 30 +++++++++++++++++++++++++++--- dlls/ddraw/ddraw.c | 2 +- dlls/wined3d/device.c | 35 ++++++++++++++++++++--------------- dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 3 ++- 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e3fee4a1cae..c1350126c3a 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -598,7 +598,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface, wined3d_mutex_lock(); wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters); - if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, reset_enum_callback))) + if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, NULL, reset_enum_callback))) { hr = wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_POINTSIZE_MIN, 0); device->lost = FALSE; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 67a2aadde4a..04a073db460 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -583,7 +583,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if wined3d_mutex_lock(); wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters); - hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, reset_enum_callback); + hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, NULL, reset_enum_callback); if (FAILED(hr)) device->not_reset = TRUE; else @@ -2954,9 +2954,33 @@ static HRESULT WINAPI d3d9_device_CreateDepthStencilSurfaceEx(IDirect3DDevice9Ex static HRESULT WINAPI d3d9_device_ResetEx(IDirect3DDevice9Ex *iface, D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode) { - FIXME("iface %p, present_parameters %p, mode %p stub!\n", iface, present_parameters, mode); + struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); + struct wined3d_swapchain_desc swapchain_desc; + struct wined3d_display_mode wined3d_mode; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, present_parameters %p, mode %p.\n", iface, present_parameters, mode); + + if (mode) + { + wined3d_mode.width = mode->Width; + wined3d_mode.height = mode->Height; + wined3d_mode.refresh_rate = mode->RefreshRate; + wined3d_mode.format_id = wined3dformat_from_d3dformat(mode->Format); + wined3d_mode.scanline_ordering = mode->ScanLineOrdering; + } + + wined3d_mutex_lock(); + wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters); + hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, + mode ? &wined3d_mode : NULL, reset_enum_callback); + if (FAILED(hr)) + device->not_reset = TRUE; + else + device->not_reset = FALSE; + wined3d_mutex_unlock(); + + return hr; } static HRESULT WINAPI d3d9_device_GetDisplayModeEx(IDirect3DDevice9Ex *iface, diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 356d726ab04..d628629a239 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3020,7 +3020,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD, swapchain_desc.backbuffer_format = mode.format_id; hr = wined3d_device_reset(ddraw->wined3d_device, - &swapchain_desc, ddraw_reset_enum_callback); + &swapchain_desc, NULL, ddraw_reset_enum_callback); if (FAILED(hr)) { ERR("Failed to reset device.\n"); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 9b73f01412b..0acbded2f40 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5136,18 +5136,18 @@ err: /* Do not call while under the GL lock. */ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, - const struct wined3d_swapchain_desc *swapchain_desc, + const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode, wined3d_device_reset_cb callback) { struct wined3d_resource *resource, *cursor; struct wined3d_swapchain *swapchain; - struct wined3d_display_mode mode; + struct wined3d_display_mode m; BOOL DisplayModeChanged = FALSE; BOOL update_desc = FALSE; unsigned int i; HRESULT hr; - TRACE("device %p, swapchain_desc %p.\n", device, swapchain_desc); + TRACE("device %p, swapchain_desc %p, mode %p, callback %p.\n", device, swapchain_desc, mode, callback); if (FAILED(hr = wined3d_device_get_swapchain(device, 0, &swapchain))) { @@ -5254,21 +5254,26 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, if (swapchain_desc->enable_auto_depth_stencil) wined3d_device_set_depth_stencil(device, device->auto_depth_stencil); - if (swapchain_desc->windowed) + if (mode) { - mode.width = swapchain->orig_width; - mode.height = swapchain->orig_height; - mode.refresh_rate = 0; - mode.format_id = swapchain->desc.backbuffer_format; - mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; + DisplayModeChanged = TRUE; + m = *mode; + } + else if (swapchain_desc->windowed) + { + m.width = swapchain->orig_width; + m.height = swapchain->orig_height; + m.refresh_rate = 0; + m.format_id = swapchain->desc.backbuffer_format; + m.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; } else { - mode.width = swapchain_desc->backbuffer_width; - mode.height = swapchain_desc->backbuffer_height; - mode.refresh_rate = swapchain_desc->refresh_rate; - mode.format_id = swapchain_desc->backbuffer_format; - mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; + m.width = swapchain_desc->backbuffer_width; + m.height = swapchain_desc->backbuffer_height; + m.refresh_rate = swapchain_desc->refresh_rate; + m.format_id = swapchain_desc->backbuffer_format; + m.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; } /* Should Width == 800 && Height == 0 set 800x600? */ @@ -5339,7 +5344,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, if (!swapchain_desc->windowed != !swapchain->desc.windowed || DisplayModeChanged) { - if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, &mode))) + if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, &m))) { WARN("Failed to set display mode, hr %#x.\n", hr); wined3d_swapchain_decref(swapchain); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 5b358b8f155..3a0ac258386 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -101,7 +101,7 @@ @ cdecl wined3d_device_present(ptr ptr ptr ptr ptr long) @ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long) @ cdecl wined3d_device_release_focus_window(ptr) -@ cdecl wined3d_device_reset(ptr ptr ptr) +@ cdecl wined3d_device_reset(ptr ptr ptr ptr) @ cdecl wined3d_device_restore_fullscreen_window(ptr ptr) @ cdecl wined3d_device_set_base_vertex_index(ptr long) @ cdecl wined3d_device_set_clip_plane(ptr long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index b85b25785e3..457693734eb 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2188,7 +2188,8 @@ HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device, const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf); void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device); HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device, - const struct wined3d_swapchain_desc *swapchain_desc, wined3d_device_reset_cb callback); + const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode, + wined3d_device_reset_cb callback); void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window); HRESULT __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index); HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device,