diff options
author | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2022-07-14 23:10:44 +0300 |
---|---|---|
committer | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2022-07-14 23:25:59 +0300 |
commit | 0f6ba59f16f76898d919ed5e4f9e8cda1cb0e9cd (patch) | |
tree | 3fc73d73fa0a4c98dd97a4491d990aac349494b8 | |
parent | b00d7f35f5f6d7f107d23bf69f3e04bea4241098 (diff) |
[dxvk] Normalize dynamic depth-stencil state based on bound attachmentvk13
We already do the same for monolothic pipelines. SpellForce 3 tries
to write depth with a read-only layout, which is a bad idea.
-rw-r--r-- | src/dxvk/dxvk_context.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index d87d129a..7c8c519a 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -4532,16 +4532,14 @@ namespace dxvk { // For pipelines created from graphics pipeline libraries, we need // to apply a bunch of dynamic state that is otherwise static if (pipelineInfo.second == DxvkGraphicsPipelineType::BasePipeline) { + VkImageAspectFlags dsReadOnlyAspects = m_state.gp.state.rt.getDepthStencilReadOnlyAspects(); + m_cmd->cmdSetDepthState( m_state.gp.state.ds.enableDepthTest(), - m_state.gp.state.ds.enableDepthWrite(), + m_state.gp.state.ds.enableDepthWrite() && + !(dsReadOnlyAspects & VK_IMAGE_ASPECT_DEPTH_BIT), m_state.gp.state.ds.depthCompareOp()); - m_cmd->cmdSetStencilState( - m_state.gp.state.ds.enableStencilTest(), - m_state.gp.state.dsFront.state(), - m_state.gp.state.dsBack.state()); - if (m_device->features().core.features.depthBounds) { m_cmd->cmdSetDepthBoundsState( m_state.gp.state.ds.enableDepthBoundsTest()); @@ -4549,12 +4547,21 @@ namespace dxvk { m_flags.set(DxvkContextFlag::GpDynamicDepthBounds); } + VkStencilOpState dsFront = m_state.gp.state.dsFront.state(); + VkStencilOpState dsBack = m_state.gp.state.dsBack.state(); + + if (dsReadOnlyAspects & VK_IMAGE_ASPECT_STENCIL_BIT) { + dsFront.writeMask = 0; + dsBack.writeMask = 0; + } + + m_cmd->cmdSetStencilState( + m_state.gp.state.ds.enableStencilTest(), + dsFront, dsBack); + m_cmd->cmdSetDepthBiasState( m_state.gp.state.rs.depthBiasEnable()); - if (!m_flags.test(DxvkContextFlag::GpDynamicRasterizerState)) - m_cmd->cmdSetRasterizerState(VK_CULL_MODE_FRONT_AND_BACK, VK_FRONT_FACE_CLOCKWISE); - m_flags.set( DxvkContextFlag::GpDynamicDepthBias, DxvkContextFlag::GpDynamicStencilRef, |