Commit ec91cd32 by Jamie Madill

Clamp stencil reference value to D3D11 8-bit limitations.

D3D11 can only mask 8 bits of a stencil reference value, so the upper bits are ignored. GL, however, expects the reference value to be able to scale to 32-bits. We will expect to fail certain edge cases where the reference value, and mask, both use particular 9+ bit values. Change-Id: I8c7451270d9e40310f4154955d38e51bbf7de4df Reviewed-on: https://chromium-review.googlesource.com/181555Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 24112d68
......@@ -786,7 +786,13 @@ void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilS
"setting the default depth stencil state.");
}
mDeviceContext->OMSetDepthStencilState(dxDepthStencilState, static_cast<UINT>(stencilRef));
// Max D3D11 stencil reference value is 0xFF, corresponding to the max 8 bits in a stencil buffer
// GL specifies we should clamp the ref value to the nearest bit depth when doing stencil ops
META_ASSERT(D3D11_DEFAULT_STENCIL_READ_MASK == 0xFF);
META_ASSERT(D3D11_DEFAULT_STENCIL_WRITE_MASK == 0xFF);
UINT stencilRef = std::min(stencilRef, 0xFFu);
mDeviceContext->OMSetDepthStencilState(dxDepthStencilState, stencilRef);
mCurDepthStencilState = depthStencilState;
mCurStencilRef = stencilRef;
......
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