Refactored Renderer::setDepthStencilState to no longer require the stencil size parameter.

TRAC #22145 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1517 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 237bc7e5
......@@ -1812,9 +1812,8 @@ void Context::applyState(GLenum drawMode)
}
mRenderer->setBlendState(mState.blend, mState.blendColor, mask);
unsigned int stencilSize = framebufferObject->hasStencil() ? framebufferObject->getStencilbuffer()->getStencilSize() : 0;
mRenderer->setDepthStencilState(mState.depthStencil, mState.stencilRef, mState.stencilBackRef,
mState.rasterizer.frontFace == GL_CCW, stencilSize);
mState.rasterizer.frontFace == GL_CCW);
}
// Applies the shaders and shader constants to the Direct3D 9 device
......
......@@ -85,7 +85,7 @@ class Renderer
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask) = 0;
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize) = 0;
int stencilBackRef, bool frontFaceCCW) = 0;
virtual void setScissorRectangle(const gl::Rectangle &scissor) = 0;
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
......
......@@ -311,7 +311,7 @@ void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color
}
void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize)
int stencilBackRef, bool frontFaceCCW)
{
if (mForceSetDepthStencilState ||
memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0 ||
......
......@@ -52,7 +52,7 @@ class Renderer11 : public Renderer
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
int stencilBackRef, bool frontFaceCCW);
virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
......
......@@ -798,14 +798,13 @@ void Renderer9::setBlendState(const gl::BlendState &blendState, const gl::Color
}
void Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize)
int stencilBackRef, bool frontFaceCCW)
{
bool depthStencilStateChanged = mForceSetDepthStencilState ||
memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0;
bool stencilRefChanged = mForceSetDepthStencilState || stencilRef != mCurStencilRef ||
stencilBackRef != mCurStencilBackRef;
bool frontFaceCCWChanged = mForceSetDepthStencilState || frontFaceCCW != mCurFrontFaceCCW;
bool stencilSizeChanged = mForceSetDepthStencilState || stencilSize != mCurStencilSize;
if (depthStencilStateChanged)
{
......@@ -822,9 +821,9 @@ void Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilSt
mCurDepthStencilState = depthStencilState;
}
if (depthStencilStateChanged || stencilRefChanged || frontFaceCCWChanged || stencilSizeChanged)
if (depthStencilStateChanged || stencilRefChanged || frontFaceCCWChanged)
{
if (depthStencilState.stencilTest && stencilSize > 0)
if (depthStencilState.stencilTest && mCurStencilSize > 0)
{
mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
......@@ -842,7 +841,7 @@ void Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilSt
}
// get the maximum size of the stencil ref
GLuint maxStencil = (1 << stencilSize) - 1;
unsigned int maxStencil = (1 << mCurStencilSize) - 1;
mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK,
depthStencilState.stencilWritemask);
......@@ -888,7 +887,6 @@ void Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilSt
mCurStencilRef = stencilRef;
mCurStencilBackRef = stencilBackRef;
mCurFrontFaceCCW = frontFaceCCW;
mCurStencilSize = stencilSize;
}
mForceSetDepthStencilState = false;
......@@ -1083,6 +1081,7 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
!mDepthStencilInitialized)
{
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
// Apply the depth stencil on the device
if (depthStencil)
......@@ -1105,6 +1104,7 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
depthStencilSurface->Release();
depthSize = depthStencil->getDepthSize();
stencilSize = depthStencil->getStencilSize();
}
else
{
......@@ -1117,6 +1117,12 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
mForceSetRasterState = true;
}
if (!mDepthStencilInitialized || stencilSize != mCurStencilSize)
{
mCurStencilSize = stencilSize;
mForceSetDepthStencilState = true;
}
mAppliedDepthbufferSerial = depthbufferSerial;
mAppliedStencilbufferSerial = stencilbufferSerial;
mDepthStencilInitialized = true;
......
......@@ -87,7 +87,7 @@ class Renderer9 : public Renderer
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
int stencilBackRef, bool frontFaceCCW);
virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
......@@ -246,6 +246,7 @@ class Renderer9 : public Renderer
bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized;
rx::RenderTarget::Desc mRenderTargetDesc;
unsigned int mCurStencilSize;
unsigned int mCurDepthSize;
IDirect3DStateBlock9 *mMaskedClearSavedState;
......@@ -256,7 +257,6 @@ class Renderer9 : public Renderer
int mCurStencilRef;
int mCurStencilBackRef;
bool mCurFrontFaceCCW;
unsigned int mCurStencilSize;
bool mForceSetRasterState;
gl::RasterizerState mCurRasterState;
......
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