Commit b685b84e authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Apply FBO state in ActivateContext().

Fixes some GL errors due to calling glDrawBuffer(GL_BACK) when an FBO is still active.
parent 9a9414df
......@@ -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) {
......
......@@ -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));
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment