Commit 79f0b4d9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Avoid resetting device state for d3d9ex resets.

parent 0a7e2acc
......@@ -597,7 +597,8 @@ 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, NULL, reset_enum_callback)))
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
NULL, reset_enum_callback, TRUE)))
{
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_POINTSIZE_MIN, 0);
device->lost = FALSE;
......
......@@ -582,8 +582,9 @@ 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, NULL, reset_enum_callback);
if (FAILED(hr))
hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
NULL, reset_enum_callback, !device->d3d_parent->extended);
if (FAILED(hr) && !device->d3d_parent->extended)
device->not_reset = TRUE;
else
device->not_reset = FALSE;
......@@ -2907,11 +2908,7 @@ static HRESULT WINAPI d3d9_device_ResetEx(IDirect3DDevice9Ex *iface,
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;
mode ? &wined3d_mode : NULL, reset_enum_callback, FALSE);
wined3d_mutex_unlock();
return hr;
......
......@@ -2867,7 +2867,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, NULL, ddraw_reset_enum_callback);
&swapchain_desc, NULL, ddraw_reset_enum_callback, TRUE);
if (FAILED(hr))
{
ERR("Failed to reset device.\n");
......
......@@ -4974,15 +4974,15 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru
/* 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_display_mode *mode,
wined3d_device_reset_cb callback)
wined3d_device_reset_cb callback, BOOL reset_state)
{
struct wined3d_resource *resource, *cursor;
struct wined3d_swapchain *swapchain;
struct wined3d_display_mode m;
BOOL DisplayModeChanged = FALSE;
BOOL update_desc = FALSE;
HRESULT hr = WINED3D_OK;
unsigned int i;
HRESULT hr;
TRACE("device %p, swapchain_desc %p, mode %p, callback %p.\n", device, swapchain_desc, mode, callback);
......@@ -4992,7 +4992,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
if (reset_state)
stateblock_unbind_resources(device->stateBlock);
if (device->fb.render_targets)
{
if (swapchain->back_buffers && swapchain->back_buffers[0])
......@@ -5012,12 +5014,15 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->onscreen_depth_stencil = NULL;
}
if (reset_state)
{
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
{
TRACE("Enumerating resource %p.\n", resource);
if (FAILED(hr = callback(resource)))
return hr;
}
}
/* Is it necessary to recreate the gl context? Actually every setting can be changed
* on an existing gl context, so there's no real need for recreation.
......@@ -5067,8 +5072,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
if (swapchain_desc->enable_auto_depth_stencil && !device->auto_depth_stencil)
{
HRESULT hr;
TRACE("Creating the depth stencil buffer\n");
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent,
......@@ -5222,6 +5225,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->exStyle = exStyle;
}
if (reset_state)
{
TRACE("Resetting stateblock.\n");
wined3d_stateblock_decref(device->updateStateBlock);
wined3d_stateblock_decref(device->stateBlock);
......@@ -5239,11 +5244,30 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
wined3d_stateblock_incref(device->updateStateBlock);
stateblock_init_default_state(device->stateBlock);
}
else
{
struct wined3d_surface *rt = device->fb.render_targets[0];
struct wined3d_state *state = &device->stateBlock->state;
/* Note the min_z / max_z is not reset. */
state->viewport.x = 0;
state->viewport.y = 0;
state->viewport.width = rt->resource.width;
state->viewport.height = rt->resource.height;
device_invalidate_state(device, STATE_VIEWPORT);
state->scissor_rect.top = 0;
state->scissor_rect.left = 0;
state->scissor_rect.right = rt->resource.width;
state->scissor_rect.bottom = rt->resource.height;
device_invalidate_state(device, STATE_SCISSORRECT);
}
swapchain_update_render_to_fbo(swapchain);
swapchain_update_draw_bindings(swapchain);
if (device->d3d_initialized)
if (reset_state && device->d3d_initialized)
hr = create_primary_opengl_context(device, swapchain);
/* All done. There is no need to reload resources or shaders, this will happen automatically on the
......
......@@ -102,7 +102,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 ptr)
@ cdecl wined3d_device_reset(ptr ptr ptr ptr long)
@ 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)
......
......@@ -2184,7 +2184,7 @@ HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,
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, const struct wined3d_display_mode *mode,
wined3d_device_reset_cb callback);
wined3d_device_reset_cb callback, BOOL reset_state);
void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window);
void __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,
......
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