wined3d: Move swapchain buffer discarding to wined3d_cs_exec_present().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2020-05-29 20:33:34 +04:30 committed by Alexandre Julliard
parent 859514a684
commit a8141ef080
2 changed files with 18 additions and 24 deletions

View File

@ -522,11 +522,14 @@ static void wined3d_cs_exec_nop(struct wined3d_cs *cs, const void *data)
static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
{
struct wined3d_texture *logo_texture, *cursor_texture, *back_buffer;
struct wined3d_rendertarget_view *dsv = cs->state.fb.depth_stencil;
const struct wined3d_cs_present *op = data;
const struct wined3d_swapchain_desc *desc;
struct wined3d_swapchain *swapchain;
unsigned int i;
swapchain = op->swapchain;
desc = &swapchain->state.desc;
back_buffer = swapchain->back_buffers[0];
wined3d_swapchain_set_window(swapchain, op->dst_window_override);
@ -557,7 +560,7 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
TRACE("Rendering the software cursor.\n");
if (swapchain->state.desc.windowed)
if (desc->windowed)
MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&dst_rect, 2);
if (wined3d_clip_blit(&clip_rect, &dst_rect, &src_rect))
wined3d_texture_blt(back_buffer, 0, &dst_rect, cursor_texture, 0,
@ -566,6 +569,19 @@ 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);
/* Discard buffers if the swap effect allows it. */
back_buffer = swapchain->back_buffers[desc->backbuffer_count - 1];
if (desc->swap_effect == WINED3D_SWAP_EFFECT_DISCARD || desc->swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
wined3d_texture_validate_location(back_buffer, 0, WINED3D_LOCATION_DISCARDED);
if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
{
struct wined3d_texture *ds = texture_from_resource(dsv->resource);
if ((desc->flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL || ds->flags & WINED3D_TEXTURE_DISCARD))
wined3d_rendertarget_view_validate_location(dsv, WINED3D_LOCATION_DISCARDED);
}
if (TRACE_ON(fps))
{
DWORD time = GetTickCount();
@ -582,7 +598,7 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
}
wined3d_resource_release(&swapchain->front_buffer->resource);
for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
for (i = 0; i < desc->backbuffer_count; ++i)
{
wined3d_resource_release(&swapchain->back_buffers[i]->resource);
}

View File

@ -467,8 +467,6 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
struct wined3d_swapchain_gl *swapchain_gl = wined3d_swapchain_gl(swapchain);
const struct wined3d_swapchain_desc *desc = &swapchain->state.desc;
struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
const struct wined3d_fb_state *fb = &swapchain->device->cs->state.fb;
struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
struct wined3d_context *context;
@ -532,26 +530,6 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE);
wined3d_texture_invalidate_location(swapchain->front_buffer, 0, ~WINED3D_LOCATION_DRAWABLE);
/* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
* and INTEXTURE copies can keep their old content if they have any defined content.
* If the swapeffect is COPY, the content remains the same.
*
* The FLIP swap effect is not implemented yet. We could mark WINED3D_LOCATION_DRAWABLE
* up to date and hope WGL flipped front and back buffers and read this data into
* the FBO. Don't bother about this for now. */
if (desc->swap_effect == WINED3D_SWAP_EFFECT_DISCARD
|| desc->swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
wined3d_texture_validate_location(swapchain->back_buffers[desc->backbuffer_count - 1],
0, WINED3D_LOCATION_DISCARDED);
if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
{
struct wined3d_texture *ds = texture_from_resource(dsv->resource);
if ((desc->flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
|| ds->flags & WINED3D_TEXTURE_DISCARD))
wined3d_texture_validate_location(ds, dsv->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
}
context_release(context);
}