D3D11: Fixed creating redundant depth/stencil state. Issue #623.

This commit is contained in:
Branimir Karadžić 2015-12-26 14:41:43 -08:00
parent 4635a0ce81
commit dcd4ab951c

View file

@ -2599,7 +2599,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
void setDepthStencilState(uint64_t _state, uint64_t _stencil = 0)
{
_state &= BGFX_D3D11_DEPTH_STENCIL_MASK;
uint32_t func = (_state&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT;
_state &= 0 == func ? 0 : BGFX_D3D11_DEPTH_STENCIL_MASK;
uint32_t fstencil = unpackStencil(0, _stencil);
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
@ -2616,7 +2617,6 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
D3D11_DEPTH_STENCIL_DESC desc;
memset(&desc, 0, sizeof(desc) );
uint32_t func = (_state&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT;
desc.DepthEnable = 0 != func;
desc.DepthWriteMask = !!(BGFX_STATE_DEPTH_WRITE & _state) ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
desc.DepthFunc = s_cmpFunc[func];