Commit c78312ad authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Merge most of d3d9_device_Reset() and d3d9_device_ResetEx().

parent 549f7b8a
...@@ -626,21 +626,28 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource) ...@@ -626,21 +626,28 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *iface, static HRESULT d3d9_device_reset(struct d3d9_device *device,
D3DPRESENT_PARAMETERS *present_parameters) D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_swapchain_desc swapchain_desc; struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_display_mode wined3d_mode;
HRESULT hr; HRESULT hr;
TRACE("iface %p, present_parameters %p.\n", iface, present_parameters);
if (!device->d3d_parent->extended && device->device_state == D3D9_DEVICE_STATE_LOST) if (!device->d3d_parent->extended && device->device_state == D3D9_DEVICE_STATE_LOST)
{ {
WARN("App not active, returning D3DERR_DEVICELOST.\n"); WARN("App not active, returning D3DERR_DEVICELOST.\n");
return D3DERR_DEVICELOST; return D3DERR_DEVICELOST;
} }
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_mutex_lock();
if (device->vertex_buffer) if (device->vertex_buffer)
...@@ -649,6 +656,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if ...@@ -649,6 +656,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if
device->vertex_buffer = NULL; device->vertex_buffer = NULL;
device->vertex_buffer_size = 0; device->vertex_buffer_size = 0;
} }
if (device->index_buffer) if (device->index_buffer)
{ {
wined3d_buffer_decref(device->index_buffer); wined3d_buffer_decref(device->index_buffer);
...@@ -657,17 +665,27 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if ...@@ -657,17 +665,27 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if
} }
wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters); wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters);
hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
NULL, reset_enum_callback, !device->d3d_parent->extended); mode ? &wined3d_mode : NULL, reset_enum_callback, !device->d3d_parent->extended)))
if (FAILED(hr) && !device->d3d_parent->extended)
device->device_state = D3D9_DEVICE_STATE_NOT_RESET;
else
device->device_state = D3D9_DEVICE_STATE_OK; device->device_state = D3D9_DEVICE_STATE_OK;
else if (!device->d3d_parent->extended)
device->device_state = D3D9_DEVICE_STATE_NOT_RESET;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *iface,
D3DPRESENT_PARAMETERS *present_parameters)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
TRACE("iface %p, present_parameters %p.\n", iface, present_parameters);
return d3d9_device_reset(device, present_parameters, NULL);
}
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex *iface, static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex *iface,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region) const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
{ {
...@@ -3253,42 +3271,10 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_ResetEx(IDirect3DDevice9Ex * ...@@ -3253,42 +3271,10 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_ResetEx(IDirect3DDevice9Ex *
D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode) D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_display_mode wined3d_mode;
HRESULT hr;
TRACE("iface %p, present_parameters %p, mode %p.\n", iface, present_parameters, mode); TRACE("iface %p, present_parameters %p, mode %p.\n", iface, present_parameters, mode);
if (mode) return d3d9_device_reset(device, present_parameters, 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();
if (device->vertex_buffer)
{
wined3d_buffer_decref(device->vertex_buffer);
device->vertex_buffer = NULL;
device->vertex_buffer_size = 0;
}
if (device->index_buffer)
{
wined3d_buffer_decref(device->index_buffer);
device->index_buffer = NULL;
device->index_buffer_size = 0;
}
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, FALSE);
wined3d_mutex_unlock();
return hr;
} }
static HRESULT WINAPI d3d9_device_GetDisplayModeEx(IDirect3DDevice9Ex *iface, static HRESULT WINAPI d3d9_device_GetDisplayModeEx(IDirect3DDevice9Ex *iface,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment