wined3d: Apply FBO state in ActivateContext().
Fixes some GL errors due to calling glDrawBuffer(GL_BACK) when an FBO is still active.
This commit is contained in:
parent
9a9414dfe2
commit
b685b84e66
|
@ -1051,7 +1051,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target)
|
static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target, BOOL blit)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IWineD3DSwapChain *swapchain;
|
IWineD3DSwapChain *swapchain;
|
||||||
|
@ -1064,11 +1064,27 @@ static void apply_draw_buffer(IWineD3DDeviceImpl *This, IWineD3DSurface *target)
|
||||||
checkGLcall("glDrawBuffers()");
|
checkGLcall("glDrawBuffers()");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
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);
|
glDrawBuffer(This->offscreenBuffer);
|
||||||
checkGLcall("glDrawBuffer()");
|
checkGLcall("glDrawBuffer()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* ActivateContext
|
* ActivateContext
|
||||||
|
@ -1135,10 +1151,34 @@ 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 */
|
/* We only need ENTER_GL for the gl calls made below and for the helper functions which make GL calls */
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
|
|
||||||
|
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) {
|
if (context->draw_buffer_dirty) {
|
||||||
apply_draw_buffer(This, target);
|
apply_draw_buffer(This, target, FALSE);
|
||||||
context->draw_buffer_dirty = 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) {
|
switch(usage) {
|
||||||
case CTXUSAGE_RESOURCELOAD:
|
case CTXUSAGE_RESOURCELOAD:
|
||||||
|
|
|
@ -5026,10 +5026,6 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa
|
||||||
ActivateContext(This, (IWineD3DSurface *) target, CTXUSAGE_CLEAR);
|
ActivateContext(This, (IWineD3DSurface *) target, CTXUSAGE_CLEAR);
|
||||||
ENTER_GL();
|
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 */
|
/* Only set the values up once, as they are not changing */
|
||||||
if (Flags & WINED3DCLEAR_STENCIL) {
|
if (Flags & WINED3DCLEAR_STENCIL) {
|
||||||
glClearStencil(Stencil);
|
glClearStencil(Stencil);
|
||||||
|
@ -6590,14 +6586,6 @@ void apply_fbo_state(IWineD3DDevice *iface) {
|
||||||
set_depth_stencil_fbo(iface, This->stencilBufferTarget);
|
set_depth_stencil_fbo(iface, This->stencilBufferTarget);
|
||||||
This->fbo_depth_attachment = 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 {
|
} else {
|
||||||
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
|
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 */
|
/* 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);
|
ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue