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:
parent
11d8eb3be4
commit
b04e9b5f18
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user