Commit 15ede106 by Jamie Madill

D3D11: Disable stencil buffer when not attached.

Similarly to the D24S8 attachment getting confused when we use only the stencil portion, ANGLE could write to the stencil portion when we were only using the depth. Fix this by internally disabling stencil test and writes when using this type of configuration. BUG=angleproject:1237 Change-Id: Ib7868d5e9f8aea73304a132005541dab947aa619 Reviewed-on: https://chromium-review.googlesource.com/314032 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 0df8fe44
......@@ -300,6 +300,7 @@ bool RenderStateCache::compareDepthStencilStates(const gl::DepthStencilState &a,
gl::Error RenderStateCache::getDepthStencilState(const gl::DepthStencilState &originalState,
bool disableDepth,
bool disableStencil,
ID3D11DepthStencilState **outDSState)
{
if (!mDevice)
......@@ -314,6 +315,13 @@ gl::Error RenderStateCache::getDepthStencilState(const gl::DepthStencilState &or
glState.depthMask = false;
}
if (disableStencil)
{
glState.stencilWritemask = 0;
glState.stencilBackWritemask = 0;
glState.stencilTest = false;
}
auto keyIter = mDepthStencilStateCache.find(glState);
if (keyIter != mDepthStencilStateCache.end())
{
......
......@@ -38,6 +38,7 @@ class RenderStateCache : angle::NonCopyable
gl::Error getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled, ID3D11RasterizerState **outRasterizerState);
gl::Error getDepthStencilState(const gl::DepthStencilState &dsState,
bool disableDepth,
bool disableStencil,
ID3D11DepthStencilState **outDSState);
gl::Error getSamplerState(const gl::SamplerState &samplerState, ID3D11SamplerState **outSamplerState);
......
......@@ -342,9 +342,13 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
// nor write to the unused depth part of this emulated texture.
bool disableDepth = (!fbo.hasDepth() && fbo.hasStencil());
// CurDisableDepth is reset automatically here if we call forceSetDepthStencilState.
// Similarly we disable the stencil portion of the DS attachment if the app only binds depth.
bool disableStencil = (fbo.hasDepth() && !fbo.hasStencil());
// CurDisableDepth/Stencil are reset automatically after we call forceSetDepthStencilState.
if (mDepthStencilStateIsDirty || !mCurDisableDepth.valid() ||
disableDepth != mCurDisableDepth.value())
disableDepth != mCurDisableDepth.value() || !mCurDisableStencil.valid() ||
disableStencil != mCurDisableStencil.value())
{
const auto &depthStencilState = glState.getDepthStencilState();
int stencilRef = glState.getStencilRef();
......@@ -364,7 +368,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
ID3D11DepthStencilState *dxDepthStencilState = NULL;
gl::Error error = mStateCache->getDepthStencilState(depthStencilState, disableDepth,
&dxDepthStencilState);
disableStencil, &dxDepthStencilState);
if (error.isError())
{
return error;
......@@ -388,6 +392,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
mCurStencilRef = stencilRef;
mCurStencilBackRef = stencilBackRef;
mCurDisableDepth = disableDepth;
mCurDisableStencil = disableStencil;
mDepthStencilStateIsDirty = false;
}
......
......@@ -62,6 +62,7 @@ class StateManager11 final : angle::NonCopyable
int mCurStencilBackRef;
unsigned int mCurStencilSize;
Optional<bool> mCurDisableDepth;
Optional<bool> mCurDisableStencil;
// Currenly applied rasterizer state
bool mRasterizerStateIsDirty;
......
......@@ -414,7 +414,6 @@
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.rg16f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r32f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.color.repeated_clear.sample.tex2d.r16f = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.stencil.attach.depth_only = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_nearest = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_src_x_nearest = FAIL
1097 WIN : dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_src_y_nearest = FAIL
......
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