From 13aeb9d1a7d9593761a51912f4afd48c6c79d603 Mon Sep 17 00:00:00 2001 From: Allan Tong Date: Thu, 13 Dec 2007 22:54:40 -0500 Subject: wined3d: Activate GL context before making any GL calls in stretch_rect_fbo. --- dlls/wined3d/device.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1793ed4..db4c5b4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6298,15 +6298,27 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED break; } - /* Attach src surface to src fbo */ src_swapchain = get_swapchain(src_surface); + dst_swapchain = get_swapchain(dst_surface); + + /* Activate GL context for onscreen surface. If there is no onscreen surface, then just make sure + there is a GL context. */ + if (src_swapchain) { + ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD); + } else if (dst_swapchain) { + ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD); + } else { + ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); + } + + ENTER_GL(); + + /* Attach src surface to src fbo */ if (src_swapchain) { GLenum buffer; TRACE("Source surface %p is onscreen\n", src_surface); - ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD); - ENTER_GL(); GL_EXTCALL(glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0)); buffer = surface_get_gl_buffer(src_surface, src_swapchain); glReadBuffer(buffer); @@ -6316,23 +6328,19 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED src_rect->y2 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y2; } else { TRACE("Source surface %p is offscreen\n", src_surface); - ENTER_GL(); + bind_fbo(iface, GL_READ_FRAMEBUFFER_EXT, &This->src_fbo); attach_surface_fbo(This, GL_READ_FRAMEBUFFER_EXT, 0, src_surface); glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); checkGLcall("glReadBuffer()"); } - LEAVE_GL(); /* Attach dst surface to dst fbo */ - dst_swapchain = get_swapchain(dst_surface); if (dst_swapchain) { GLenum buffer; TRACE("Destination surface %p is onscreen\n", dst_surface); - ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD); - ENTER_GL(); GL_EXTCALL(glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)); buffer = surface_get_gl_buffer(dst_surface, dst_swapchain); glDrawBuffer(buffer); @@ -6343,12 +6351,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED } else { TRACE("Destination surface %p is offscreen\n", dst_surface); - /* No src or dst swapchain? Make sure some context is active(multithreading) */ - if(!src_swapchain) { - ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); - } - - ENTER_GL(); bind_fbo(iface, GL_DRAW_FRAMEBUFFER_EXT, &This->dst_fbo); attach_surface_fbo(This, GL_DRAW_FRAMEBUFFER_EXT, 0, dst_surface); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); -- 1.5.2.5