Preserve the scissor and viewport rectangles on swap and blit

TRAC #14054 The SetRenderTarget calls used in Blit::boxFilter() and Surface::swap() implicitly reset the scissor and viewport rectangles. So we need to ensure that the original rectangles get captured, and restored afterwards (the Context only keeps track of explicitly changed state). Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@472 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 24e39699
...@@ -220,6 +220,7 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device) ...@@ -220,6 +220,7 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device)
device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE); device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
device->SetPixelShader(NULL); device->SetPixelShader(NULL);
device->SetVertexShader(NULL); device->SetVertexShader(NULL);
...@@ -236,6 +237,11 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device) ...@@ -236,6 +237,11 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device)
device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
device->SetStreamSourceFreq(0, 1); // DrawPrimitiveUP only cares about stream 0, not the rest. device->SetStreamSourceFreq(0, 1); // DrawPrimitiveUP only cares about stream 0, not the rest.
RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle
device->SetScissorRect(&scissorRect);
D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
device->SetViewport(&viewport);
} }
void Surface::applyFlipState(IDirect3DDevice9 *device) void Surface::applyFlipState(IDirect3DDevice9 *device)
...@@ -296,8 +302,6 @@ void Surface::applyFlipState(IDirect3DDevice9 *device) ...@@ -296,8 +302,6 @@ void Surface::applyFlipState(IDirect3DDevice9 *device)
void Surface::restoreState(IDirect3DDevice9 *device) void Surface::restoreState(IDirect3DDevice9 *device)
{ {
mPreFlipState->Apply();
device->SetRenderTarget(0, mPreFlipBackBuffer); device->SetRenderTarget(0, mPreFlipBackBuffer);
device->SetDepthStencilSurface(mPreFlipDepthStencil); device->SetDepthStencilSurface(mPreFlipDepthStencil);
...@@ -312,6 +316,8 @@ void Surface::restoreState(IDirect3DDevice9 *device) ...@@ -312,6 +316,8 @@ void Surface::restoreState(IDirect3DDevice9 *device)
mPreFlipDepthStencil->Release(); mPreFlipDepthStencil->Release();
mPreFlipDepthStencil = NULL; mPreFlipDepthStencil = NULL;
} }
mPreFlipState->Apply();
} }
// On the next flip, this will cause the state to be recorded from scratch. // On the next flip, this will cause the state to be recorded from scratch.
......
...@@ -470,6 +470,9 @@ void Blit::setCommonBlitState() ...@@ -470,6 +470,9 @@ void Blit::setCommonBlitState()
{ {
device->SetStreamSourceFreq(i, 1); device->SetStreamSourceFreq(i, 1);
} }
RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle
device->SetScissorRect(&scissorRect);
} }
void Blit::render() void Blit::render()
......
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