wined3d: Blitting to offscreen target.
Fix the NULL deref that occured when blitting to offscreen targets and select the proper gl drawing buffer instead.
This commit is contained in:
parent
a66784c7d1
commit
0b46254b57
|
@ -690,7 +690,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
|
||||||
object->pow2Height = pow2Height;
|
object->pow2Height = pow2Height;
|
||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
object->Flags = 0; /* We start without flags set */
|
object->Flags = SFLAG_DYNLOCK;
|
||||||
object->Flags |= (pow2Width != Width || pow2Height != Height) ? SFLAG_NONPOW2 : 0;
|
object->Flags |= (pow2Width != Width || pow2Height != Height) ? SFLAG_NONPOW2 : 0;
|
||||||
object->Flags |= Discard ? SFLAG_DISCARD : 0;
|
object->Flags |= Discard ? SFLAG_DISCARD : 0;
|
||||||
object->Flags |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
|
object->Flags |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
|
||||||
|
|
|
@ -2637,7 +2637,6 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
DWORD oldCKeyFlags = Src->CKeyFlags;
|
DWORD oldCKeyFlags = Src->CKeyFlags;
|
||||||
DDCOLORKEY oldBltCKey = This->SrcBltCKey;
|
DDCOLORKEY oldBltCKey = This->SrcBltCKey;
|
||||||
RECT SourceRectangle;
|
RECT SourceRectangle;
|
||||||
GLint oldDraw;
|
|
||||||
|
|
||||||
TRACE("Blt from surface %p to rendertarget %p\n", Src, This);
|
TRACE("Blt from surface %p to rendertarget %p\n", Src, This);
|
||||||
|
|
||||||
|
@ -2687,11 +2686,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
/* Activate the destination context, set it up for blitting */
|
/* Activate the destination context, set it up for blitting */
|
||||||
ActivateContext(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
|
ActivateContext(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
|
||||||
|
|
||||||
glGetIntegerv(GL_DRAW_BUFFER, &oldDraw);
|
if(!dstSwapchain) {
|
||||||
if(This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer) {
|
TRACE("Drawing to offscreen buffer\n");
|
||||||
|
glDrawBuffer(myDevice->offscreenBuffer);
|
||||||
|
} else if(This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer) {
|
||||||
TRACE("Drawing to front buffer\n");
|
TRACE("Drawing to front buffer\n");
|
||||||
glDrawBuffer(GL_FRONT);
|
glDrawBuffer(GL_FRONT);
|
||||||
checkGLcall("glDrawBuffer GL_FRONT");
|
checkGLcall("glDrawBuffer GL_FRONT");
|
||||||
|
} else {
|
||||||
|
TRACE("Drawing to back buffer\n");
|
||||||
|
glDrawBuffer(GL_BACK);
|
||||||
|
checkGLcall("glDrawBuffer GL_BACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind the texture */
|
/* Bind the texture */
|
||||||
|
@ -2722,7 +2727,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a textured quad
|
/* Draw a textured quad
|
||||||
*/
|
*/
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glColor3d(1.0f, 1.0f, 1.0f);
|
glColor3d(1.0f, 1.0f, 1.0f);
|
||||||
|
@ -2755,8 +2760,11 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
checkGLcall("glEnable glBindTexture");
|
checkGLcall("glEnable glBindTexture");
|
||||||
|
|
||||||
if(This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer && oldDraw == GL_BACK) {
|
/* The draw buffer should only need to be restored if we were drawing to the front buffer, and there is a back buffer.
|
||||||
glDrawBuffer(oldDraw);
|
* otherwise the context manager should choose between GL_BACK / offscreenDrawBuffer
|
||||||
|
*/
|
||||||
|
if(dstSwapchain && This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer && dstSwapchain->backBuffer) {
|
||||||
|
glDrawBuffer(GL_BACK);
|
||||||
}
|
}
|
||||||
/* Restore the color key parameters */
|
/* Restore the color key parameters */
|
||||||
Src->CKeyFlags = oldCKeyFlags;
|
Src->CKeyFlags = oldCKeyFlags;
|
||||||
|
|
Loading…
Reference in New Issue