Module: wine Branch: master Commit: b685b84e667dd8c32fa4a9e76c2c428d8f48d306 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b685b84e667dd8c32fa4a9e76c...
Author: H. Verbeet hverbeet@gmail.com Date: Mon Aug 4 19:28:37 2008 +0200
wined3d: Apply FBO state in ActivateContext().
Fixes some GL errors due to calling glDrawBuffer(GL_BACK) when an FBO is still active.
---
dlls/wined3d/context.c | 52 +++++++++++++++++++++++++++++++++++++++++----- dlls/wined3d/device.c | 12 ---------- dlls/wined3d/drawprim.c | 6 ----- 3 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 3556714..56111ef 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1051,7 +1051,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf return context; }
-static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target) +static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target, BOOL blit) { HRESULT hr; IWineD3DSwapChain *swapchain; @@ -1065,8 +1065,24 @@ static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target) } else { - glDrawBuffer(This->offscreenBuffer); - checkGLcall("glDrawBuffer()"); + if (!blit && wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + if (GL_SUPPORT(ARB_DRAW_BUFFERS)) + { + GL_EXTCALL(glDrawBuffersARB(GL_LIMITS(buffers), This->draw_buffers)); + checkGLcall("glDrawBuffers()"); + } + else + { + glDrawBuffer(This->draw_buffers[0]); + checkGLcall("glDrawBuffer()"); + } + } + else + { + glDrawBuffer(This->offscreenBuffer); + checkGLcall("glDrawBuffer()"); + } } }
@@ -1135,9 +1151,33 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU /* We only need ENTER_GL for the gl calls made below and for the helper functions which make GL calls */ ENTER_GL();
- if (context->draw_buffer_dirty) { - apply_draw_buffer(This, target); - context->draw_buffer_dirty = FALSE; + switch (usage) { + case CTXUSAGE_CLEAR: + case CTXUSAGE_DRAWPRIM: + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { + apply_fbo_state((IWineD3DDevice *)This); + } + if (context->draw_buffer_dirty) { + apply_draw_buffer(This, target, FALSE); + context->draw_buffer_dirty = FALSE; + } + break; + + case CTXUSAGE_BLIT: + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { + GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)); + context->draw_buffer_dirty = TRUE; + } + if (context->draw_buffer_dirty) { + apply_draw_buffer(This, target, TRUE); + if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) { + context->draw_buffer_dirty = FALSE; + } + } + break; + + default: + break; }
switch(usage) { diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 55c1f46..7867517 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5026,10 +5026,6 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa ActivateContext(This, (IWineD3DSurface *) target, CTXUSAGE_CLEAR); ENTER_GL();
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { - apply_fbo_state((IWineD3DDevice *) This); - } - /* Only set the values up once, as they are not changing */ if (Flags & WINED3DCLEAR_STENCIL) { glClearStencil(Stencil); @@ -6590,14 +6586,6 @@ void apply_fbo_state(IWineD3DDevice *iface) { set_depth_stencil_fbo(iface, This->stencilBufferTarget); This->fbo_depth_attachment = This->stencilBufferTarget; } - - if (GL_SUPPORT(ARB_DRAW_BUFFERS)) { - GL_EXTCALL(glDrawBuffersARB(GL_LIMITS(buffers), This->draw_buffers)); - checkGLcall("glDrawBuffers()"); - } else { - glDrawBuffer(This->draw_buffers[0]); - checkGLcall("glDrawBuffer()"); - } } else { GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)); } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index fd96ea2..59e1f64 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -941,12 +941,6 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Ok, we will be updating the screen from here onwards so grab the lock */
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { - ENTER_GL(); - apply_fbo_state(iface); - LEAVE_GL(); - } - ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM); ENTER_GL();