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

wined3d: Move the "desc" field from struct wined3d_swapchain to struct wined3d_swapchain_state.

parent 3fc96a5d
......@@ -530,7 +530,7 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->swap_interval, op->flags);
wined3d_resource_release(&swapchain->front_buffer->resource);
for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
{
wined3d_resource_release(&swapchain->back_buffers[i]->resource);
}
......@@ -558,7 +558,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
pending = InterlockedIncrement(&cs->pending_presents);
wined3d_resource_acquire(&swapchain->front_buffer->resource);
for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
{
wined3d_resource_acquire(&swapchain->back_buffers[i]->resource);
}
......@@ -1137,7 +1137,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
{
struct wined3d_texture *prev_texture = texture_from_resource(prev->resource);
if (device->swapchains[0]->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
if (device->swapchains[0]->state.desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
|| prev_texture->flags & WINED3D_TEXTURE_DISCARD)
wined3d_texture_validate_location(prev_texture,
prev->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
......
......@@ -936,7 +936,7 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{
BOOL ds_enable = swapchain->desc.enable_auto_depth_stencil;
BOOL ds_enable = swapchain->state.desc.enable_auto_depth_stencil;
unsigned int i;
for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i)
......@@ -1044,7 +1044,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
if (device->d3d_initialized)
return WINED3DERR_INVALIDCALL;
swapchain_desc = &swapchain->desc;
swapchain_desc = &swapchain->state.desc;
if (swapchain_desc->backbuffer_count && swapchain_desc->backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
{
struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
......@@ -5294,7 +5294,7 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device)
static void update_swapchain_flags(struct wined3d_texture *texture)
{
unsigned int flags = texture->swapchain->desc.flags;
unsigned int flags = texture->swapchain->state.desc.flags;
if (flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER)
texture->resource.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
......@@ -5312,6 +5312,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
wined3d_device_reset_cb callback, BOOL reset_state)
{
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
struct wined3d_swapchain_state *swapchain_state;
struct wined3d_swapchain_desc *current_desc;
struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view;
struct wined3d_swapchain *swapchain;
......@@ -5330,6 +5332,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
ERR("Failed to get the first implicit swapchain.\n");
return WINED3DERR_INVALIDCALL;
}
swapchain_state = &swapchain->state;
current_desc = &swapchain_state->desc;
if (reset_state)
{
......@@ -5389,25 +5393,24 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
FIXME("Unimplemented swap effect %#x.\n", swapchain_desc->swap_effect);
/* No special treatment of these parameters. Just store them */
swapchain->desc.swap_effect = swapchain_desc->swap_effect;
swapchain->desc.enable_auto_depth_stencil = swapchain_desc->enable_auto_depth_stencil;
swapchain->desc.auto_depth_stencil_format = swapchain_desc->auto_depth_stencil_format;
swapchain->desc.refresh_rate = swapchain_desc->refresh_rate;
swapchain->desc.auto_restore_display_mode = swapchain_desc->auto_restore_display_mode;
current_desc->swap_effect = swapchain_desc->swap_effect;
current_desc->enable_auto_depth_stencil = swapchain_desc->enable_auto_depth_stencil;
current_desc->auto_depth_stencil_format = swapchain_desc->auto_depth_stencil_format;
current_desc->refresh_rate = swapchain_desc->refresh_rate;
current_desc->auto_restore_display_mode = swapchain_desc->auto_restore_display_mode;
if (swapchain_desc->device_window
&& swapchain_desc->device_window != swapchain->desc.device_window)
if (swapchain_desc->device_window && swapchain_desc->device_window != current_desc->device_window)
{
TRACE("Changing the device window from %p to %p.\n",
swapchain->desc.device_window, swapchain_desc->device_window);
swapchain->desc.device_window = swapchain_desc->device_window;
current_desc->device_window, swapchain_desc->device_window);
current_desc->device_window = swapchain_desc->device_window;
swapchain->device_window = swapchain_desc->device_window;
wined3d_swapchain_set_window(swapchain, NULL);
}
backbuffer_resized = swapchain_desc->backbuffer_width != swapchain->desc.backbuffer_width
|| swapchain_desc->backbuffer_height != swapchain->desc.backbuffer_height;
windowed = swapchain->desc.windowed;
backbuffer_resized = swapchain_desc->backbuffer_width != current_desc->backbuffer_width
|| swapchain_desc->backbuffer_height != current_desc->backbuffer_height;
windowed = current_desc->windowed;
if (!swapchain_desc->windowed != !windowed || swapchain->reapply_mode
|| mode || (!swapchain_desc->windowed && backbuffer_resized))
......@@ -5434,18 +5437,18 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
}
else if (!swapchain_desc->windowed)
{
DWORD style = swapchain->state.style;
DWORD exstyle = swapchain->state.exstyle;
DWORD style = swapchain_state->style;
DWORD exstyle = swapchain_state->exstyle;
/* If we're in fullscreen, and the mode wasn't changed, we have to get
* the window back into the right position. Some applications
* (Battlefield 2, Guild Wars) move it and then call Reset() to clean
* up their mess. Guild Wars also loses the device during that. */
swapchain->state.style = 0;
swapchain->state.exstyle = 0;
wined3d_swapchain_state_setup_fullscreen(&swapchain->state, swapchain->device_window,
swapchain_state->style = 0;
swapchain_state->exstyle = 0;
wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain->device_window,
swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height);
swapchain->state.style = style;
swapchain->state.exstyle = exstyle;
swapchain_state->style = style;
swapchain_state->exstyle = exstyle;
}
if (FAILED(hr = wined3d_swapchain_resize_buffers(swapchain, swapchain_desc->backbuffer_count,
......@@ -5453,12 +5456,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
swapchain_desc->multisample_type, swapchain_desc->multisample_quality)))
return hr;
if (swapchain_desc->flags != swapchain->desc.flags)
if (swapchain_desc->flags != current_desc->flags)
{
swapchain->desc.flags = swapchain_desc->flags;
current_desc->flags = swapchain_desc->flags;
update_swapchain_flags(swapchain->front_buffer);
for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
for (i = 0; i < current_desc->backbuffer_count; ++i)
{
update_swapchain_flags(swapchain->back_buffers[i]);
}
......@@ -5469,7 +5472,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->auto_depth_stencil_view = NULL;
wined3d_rendertarget_view_decref(view);
}
if (swapchain->desc.enable_auto_depth_stencil)
if (current_desc->enable_auto_depth_stencil)
{
struct wined3d_resource_desc texture_desc;
struct wined3d_texture *texture;
......@@ -5477,14 +5480,14 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
TRACE("Creating the depth stencil buffer.\n");
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
texture_desc.multisample_type = swapchain->desc.multisample_type;
texture_desc.multisample_quality = swapchain->desc.multisample_quality;
texture_desc.format = current_desc->auto_depth_stencil_format;
texture_desc.multisample_type = current_desc->multisample_type;
texture_desc.multisample_quality = current_desc->multisample_quality;
texture_desc.usage = 0;
texture_desc.bind_flags = WINED3D_BIND_DEPTH_STENCIL;
texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
texture_desc.width = swapchain->desc.backbuffer_width;
texture_desc.height = swapchain->desc.backbuffer_height;
texture_desc.width = current_desc->backbuffer_width;
texture_desc.height = current_desc->backbuffer_height;
texture_desc.depth = 1;
texture_desc.size = 0;
......@@ -5518,7 +5521,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->back_buffer_view = NULL;
wined3d_rendertarget_view_decref(view);
}
if (swapchain->desc.backbuffer_count && swapchain->desc.backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
if (current_desc->backbuffer_count && current_desc->backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
{
struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
......
......@@ -3086,16 +3086,16 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_
* Prince of Persia 3D use Blt() from the backbuffer to the
* frontbuffer instead of doing a Flip(). D3d8 and d3d9 applications
* can't blit directly to the frontbuffer. */
enum wined3d_swap_effect swap_effect = dst_swapchain->desc.swap_effect;
enum wined3d_swap_effect swap_effect = dst_swapchain->state.desc.swap_effect;
TRACE("Using present for backbuffer -> frontbuffer blit.\n");
/* Set the swap effect to COPY, we don't want the backbuffer to become
* undefined. */
dst_swapchain->desc.swap_effect = WINED3D_SWAP_EFFECT_COPY;
dst_swapchain->state.desc.swap_effect = WINED3D_SWAP_EFFECT_COPY;
wined3d_swapchain_present(dst_swapchain, NULL, NULL,
dst_swapchain->win_handle, dst_swapchain->swap_interval, 0);
dst_swapchain->desc.swap_effect = swap_effect;
dst_swapchain->state.desc.swap_effect = swap_effect;
return WINED3D_OK;
}
......
......@@ -446,13 +446,13 @@ void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarg
}
else if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
const struct wined3d_swapchain *swapchain = context->swapchain;
const struct wined3d_swapchain_desc *desc = &context->swapchain->state.desc;
/* The drawable size of a backbuffer / aux buffer offscreen target is
* the size of the current context's drawable, which is the size of
* the back buffer of the swapchain the active context belongs to. */
*width = swapchain->desc.backbuffer_width;
*height = swapchain->desc.backbuffer_height;
*width = desc->backbuffer_width;
*height = desc->backbuffer_height;
}
else
{
......@@ -562,7 +562,7 @@ static void wined3d_render_target_view_gl_cs_init(void *object)
debug_d3dformat(resource->format->id), debug_d3dformat(view_gl->v.format->id));
return;
}
if (texture_gl->t.swapchain && texture_gl->t.swapchain->desc.backbuffer_count > 1)
if (texture_gl->t.swapchain && texture_gl->t.swapchain->state.desc.backbuffer_count > 1)
{
FIXME("Swapchain views not supported.\n");
return;
......@@ -761,7 +761,7 @@ static void wined3d_shader_resource_view_gl_cs_init(void *object)
{
TRACE("Creating identity shader resource view.\n");
}
else if (texture_gl->t.swapchain && texture_gl->t.swapchain->desc.backbuffer_count > 1)
else if (texture_gl->t.swapchain && texture_gl->t.swapchain->state.desc.backbuffer_count > 1)
{
FIXME("Swapchain shader resource views not supported.\n");
}
......
......@@ -4176,6 +4176,8 @@ static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_
struct wined3d_swapchain_state
{
struct wined3d_swapchain_desc desc;
/* Window styles to restore when switching fullscreen mode. */
LONG style;
LONG exstyle;
......@@ -4203,7 +4205,6 @@ struct wined3d_swapchain
struct wined3d_texture **back_buffers;
struct wined3d_texture *front_buffer;
struct wined3d_swapchain_desc desc;
struct wined3d_display_mode original_mode, d3d_mode;
RECT original_window_rect;
struct wined3d_gamma_ramp orig_gamma;
......
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