From: Matteo Bruni mbruni@codeweavers.com
--- dlls/wined3d/context_gl.c | 90 +++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 50 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index a0a21a0be20..5597ef9e281 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3236,46 +3236,46 @@ 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)); }
-/* 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) +static void wined3d_context_gl_apply_blit_state_fb(struct wined3d_context_gl *context_gl, + 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; - const struct wined3d_gl_info *gl_info; uint32_t rt_mask, *cur_mask; - struct wined3d_texture *rt; - unsigned int sampler; - SIZE rt_size;
- TRACE("Setting up context %p for blitting.\n", context); + TRACE("context_gl %p, texture %p, sub_resource_idx %u, location %s.\n", + context_gl, texture, sub_resource_idx, wined3d_debug_location(location));
- gl_info = context_gl->gl_info; - rt = context->current_rt.texture; + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + 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); + else + wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER, &texture->resource, + sub_resource_idx, NULL, 0, location); + }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { - if (context->render_offscreen) + if (location != WINED3D_LOCATION_DRAWABLE) { - wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_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 + if (texture->resource.format->id == WINED3DFMT_NULL || format->depth_size || format->stencil_size) rt_mask = 0; + else + rt_mask = 1; } else { - context_gl->current_fbo = NULL; - wined3d_context_gl_bind_fbo(context_gl, GL_DRAW_FRAMEBUFFER, 0); - rt_mask = context_generate_rt_mask_from_resource(&rt->resource); + rt_mask = context_generate_rt_mask_from_resource(&texture->resource); } } else { - rt_mask = wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, &rt->resource); + rt_mask = wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, &texture->resource); }
cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask; - if (rt_mask != *cur_mask) { wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask); @@ -3284,7 +3284,26 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER); + 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) +{ + struct wined3d_context *context = &context_gl->c; + const struct wined3d_gl_info *gl_info; + struct wined3d_texture *rt; + unsigned int sampler; + SIZE rt_size; + + TRACE("Setting up context %p for blitting.\n", context); + + gl_info = context_gl->gl_info; + rt = context->current_rt.texture; + + wined3d_context_gl_apply_blit_state_fb(context_gl, rt, context->current_rt.sub_resource_idx, + rt->resource.draw_binding);
wined3d_context_gl_get_rt_size(context_gl, &rt_size);
@@ -3642,39 +3661,10 @@ static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_ void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx, unsigned int location) { - const struct wined3d_format *format = texture->resource.format; - GLenum buffer; - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return;
- 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); - buffer = wined3d_texture_get_gl_buffer(texture); - } - else - { - TRACE("Texture %p is offscreen.\n", texture); - buffer = GL_COLOR_ATTACHMENT0; - } - } - - 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); + wined3d_context_gl_apply_blit_state_fb(context_gl, texture, sub_resource_idx, location); }
/* Context activation is done by the caller. */