1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-29 17:52:18 +01:00

[d3d11] Refactored D3D11DepthStencilState creation

This commit is contained in:
Philip Rebohle 2018-03-18 23:32:01 +01:00
parent 11d8eb3be4
commit b04e9b5f18
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 37 additions and 19 deletions

View File

@ -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 {

View File

@ -33,6 +33,11 @@ namespace dxvk {
void BindToContext(
const Rc<DxvkContext>& ctx);
static D3D11_DEPTH_STENCIL_DESC DefaultDesc();
static HRESULT NormalizeDesc(
D3D11_DEPTH_STENCIL_DESC* pDesc);
private:
D3D11Device* const m_device;

View File

@ -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);