From: Matteo Bruni mbruni@codeweavers.com
--- dlls/wined3d/context_gl.c | 51 +++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index a8c5160a5b3..5b3630bf159 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3236,6 +3236,34 @@ static uint32_t wined3d_context_gl_generate_rt_mask_no_fbo(const struct wined3d_ return context_generate_rt_mask(wined3d_context_gl_get_offscreen_gl_buffer(context_gl)); }
+void wined3d_context_gl_apply_blit_state_fbo(struct wined3d_context_gl *context_gl, GLenum target, + struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location) +{ + const struct wined3d_format *format = texture->resource.format; + struct wined3d_context *context = &context_gl->c; + + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + if (location != WINED3D_LOCATION_DRAWABLE) + { + if (format->depth_size || format->stencil_size) + wined3d_context_gl_apply_fbo_state_blit(context_gl, target, NULL, + 0, &texture->resource, sub_resource_idx, location); + else + wined3d_context_gl_apply_fbo_state_blit(context_gl, target, &texture->resource, + sub_resource_idx, NULL, 0, location); + } + else + { + context_gl->current_fbo = NULL; + wined3d_context_gl_bind_fbo(context_gl, target, 0); + } + wined3d_context_gl_check_fbo_status(context_gl, target); + } + + context_invalidate_state(context, STATE_FRAMEBUFFER); +} + /* Context activation is done by the caller. */ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, const struct wined3d_device *device) { @@ -3251,14 +3279,13 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, gl_info = context_gl->gl_info; rt = context->current_rt.texture;
+ wined3d_context_gl_apply_blit_state_fbo(context_gl, GL_FRAMEBUFFER, rt, context->current_rt.sub_resource_idx, + rt->resource.draw_binding); + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { if (context->render_offscreen) { - wined3d_texture_load(rt, context, FALSE); - - wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_FRAMEBUFFER, &rt->resource, - context->current_rt.sub_resource_idx, NULL, 0, rt->resource.draw_binding); if (rt->resource.format->id != WINED3DFMT_NULL) rt_mask = 1; else @@ -3266,8 +3293,6 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, } else { - context_gl->current_fbo = NULL; - wined3d_context_gl_bind_fbo(context_gl, GL_FRAMEBUFFER, 0); rt_mask = context_generate_rt_mask_from_resource(&rt->resource); } } @@ -3284,10 +3309,6 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, *cur_mask = rt_mask; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - wined3d_context_gl_check_fbo_status(context_gl, GL_FRAMEBUFFER); - context_invalidate_state(context, STATE_FRAMEBUFFER); - wined3d_context_gl_get_rt_size(context_gl, &rt_size);
if (context->last_was_blit) @@ -3650,18 +3671,14 @@ void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl, if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return;
+ wined3d_context_gl_apply_blit_state_fbo(context_gl, GL_DRAW_FRAMEBUFFER, + texture, sub_resource_idx, location); if (format->depth_size || format->stencil_size) { - wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER, - NULL, 0, &texture->resource, sub_resource_idx, location); - buffer = GL_NONE; } else { - wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER, - &texture->resource, sub_resource_idx, NULL, 0, location); - if (location == WINED3D_LOCATION_DRAWABLE) { TRACE("Texture %p is onscreen.\n", texture); @@ -3675,8 +3692,6 @@ void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl, }
wined3d_context_gl_set_draw_buffer(context_gl, buffer); - wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER); - context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER); }
/* Context activation is done by the caller. */