diff --git a/src/d3d11/d3d11_depth_stencil.cpp b/src/d3d11/d3d11_depth_stencil.cpp index 444b1efe5..66886166f 100644 --- a/src/d3d11/d3d11_depth_stencil.cpp +++ b/src/d3d11/d3d11_depth_stencil.cpp @@ -51,6 +51,33 @@ namespace dxvk { } + D3D11_DEPTH_STENCIL_DESC D3D11DepthStencilState::DefaultDesc() { + D3D11_DEPTH_STENCILOP_DESC stencilOp; + stencilOp.StencilFunc = D3D11_COMPARISON_ALWAYS; + stencilOp.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + stencilOp.StencilPassOp = D3D11_STENCIL_OP_KEEP; + stencilOp.StencilFailOp = D3D11_STENCIL_OP_KEEP; + + D3D11_DEPTH_STENCIL_DESC dstDesc; + dstDesc.DepthEnable = TRUE; + dstDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + dstDesc.DepthFunc = D3D11_COMPARISON_LESS; + dstDesc.StencilEnable = FALSE; + dstDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; + dstDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; + dstDesc.FrontFace = stencilOp; + dstDesc.BackFace = stencilOp; + return dstDesc; + } + + + HRESULT D3D11DepthStencilState::NormalizeDesc(D3D11_DEPTH_STENCIL_DESC* pDesc) { + // TODO validate + // TODO clear unused values + return S_OK; + } + + VkStencilOpState D3D11DepthStencilState::DecodeStencilOpState( const D3D11_DEPTH_STENCILOP_DESC& StencilDesc, const D3D11_DEPTH_STENCIL_DESC& Desc) const { diff --git a/src/d3d11/d3d11_depth_stencil.h b/src/d3d11/d3d11_depth_stencil.h index c1d171eb3..3ceb7008f 100644 --- a/src/d3d11/d3d11_depth_stencil.h +++ b/src/d3d11/d3d11_depth_stencil.h @@ -33,6 +33,11 @@ namespace dxvk { void BindToContext( const Rc& ctx); + static D3D11_DEPTH_STENCIL_DESC DefaultDesc(); + + static HRESULT NormalizeDesc( + D3D11_DEPTH_STENCIL_DESC* pDesc); + private: D3D11Device* const m_device; diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index affe10753..f08ece4c4 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1114,26 +1114,12 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D11Device::CreateDepthStencilState( const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, ID3D11DepthStencilState** ppDepthStencilState) { - D3D11_DEPTH_STENCIL_DESC desc; + D3D11_DEPTH_STENCIL_DESC desc = pDepthStencilDesc != nullptr + ? *pDepthStencilDesc + : D3D11DepthStencilState::DefaultDesc(); - if (pDepthStencilDesc != nullptr) { - desc = *pDepthStencilDesc; - } else { - D3D11_DEPTH_STENCILOP_DESC stencilOp; - stencilOp.StencilFunc = D3D11_COMPARISON_ALWAYS; - stencilOp.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - stencilOp.StencilPassOp = D3D11_STENCIL_OP_KEEP; - stencilOp.StencilFailOp = D3D11_STENCIL_OP_KEEP; - - desc.DepthEnable = TRUE; - desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - desc.DepthFunc = D3D11_COMPARISON_LESS; - desc.StencilEnable = FALSE; - desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; - desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; - desc.FrontFace = stencilOp; - desc.BackFace = stencilOp; - } + if (FAILED(D3D11DepthStencilState::NormalizeDesc(&desc))) + return E_INVALIDARG; if (ppDepthStencilState != nullptr) { *ppDepthStencilState = m_dsStateObjects.Create(this, desc);