wined3d: Don't apply and invalidate the framebuffer when clearing the device's fb.

This commit is contained in:
Stefan Dösinger 2011-06-08 00:49:58 +02:00 committed by Alexandre Julliard
parent dafd6fecd1
commit f99a2748e4
1 changed files with 44 additions and 26 deletions

View File

@ -2073,17 +2073,19 @@ BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_d
UINT i; UINT i;
struct wined3d_surface **rts = fb->render_targets; struct wined3d_surface **rts = fb->render_targets;
if (!context_validate_rt_config(rt_count, rts, fb->depth_stencil)) if (isStateDirty(context, STATE_FRAMEBUFFER) || fb != &device->fb
|| rt_count != device->adapter->gl_info.limits.buffers)
{
if (!context_validate_rt_config(rt_count, fb->render_targets, fb->depth_stencil))
return FALSE; return FALSE;
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{ {
context_validate_onscreen_formats(device, context, fb->depth_stencil); context_validate_onscreen_formats(device, context, fb->depth_stencil);
ENTER_GL(); ENTER_GL();
if (!rt_count || surface_is_offscreen(rts[0])) if (!rt_count || surface_is_offscreen(fb->render_targets[0]))
{ {
for (i = 0; i < rt_count; ++i) for (i = 0; i < rt_count; ++i)
{ {
@ -2103,24 +2105,40 @@ BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_d
else else
{ {
context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, NULL, SFLAG_INDRAWABLE); context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, NULL, SFLAG_INDRAWABLE);
rt_mask = context_generate_rt_mask_from_surface(rts[0]); rt_mask = context_generate_rt_mask_from_surface(fb->render_targets[0]);
} }
LEAVE_GL(); LEAVE_GL();
/* TODO: This is not necessary if the framebuffer is the device's current framebuffer */ /* If the framebuffer is not the device's fb the device's fb has to be reapplied
* next draw. Otherwise we could mark the framebuffer state clean here, once the
* state management allows this */
context_invalidate_state(context, STATE_FRAMEBUFFER, device->StateTable); context_invalidate_state(context, STATE_FRAMEBUFFER, device->StateTable);
} }
else else
{ {
rt_mask = context_generate_rt_mask_no_fbo(device, rts[0]); rt_mask = context_generate_rt_mask_no_fbo(device, rts[0]);
} }
}
else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
&& (!rt_count || surface_is_offscreen(fb->render_targets[0])))
{
for (i = 0; i < rt_count; ++i)
{
if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL) rt_mask |= (1 << i);
}
}
else
{
rt_mask = context_generate_rt_mask_no_fbo(device, rts[0]);
}
ENTER_GL(); ENTER_GL();
if (rt_mask != context->draw_buffers_mask) if (rt_mask != context->draw_buffers_mask)
{ {
context_apply_draw_buffers(context, rt_mask); context_apply_draw_buffers(context, rt_mask);
context->draw_buffers_mask = rt_mask; context->draw_buffers_mask = rt_mask;
context_invalidate_state(context, STATE_FRAMEBUFFER, device->StateTable);
} }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)