From bdafa16e39b5295acdc31cc581cba94295228c7f Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Tue, 29 Mar 2022 22:46:11 +0200 Subject: [PATCH] [d3d9] Only bind depth buffer if the depth or stencil test is enabled --- src/d3d9/d3d9_device.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index baeb28a39..d4140de5f 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -1922,17 +1922,17 @@ namespace dxvk { m_flags.set(D3D9DeviceFlag::DirtyMultiSampleState); break; + case D3DRS_STENCILENABLE: case D3DRS_ZWRITEENABLE: - if (m_activeHazardsDS != 0) + case D3DRS_ZENABLE: + if (likely(m_state.depthStencil != nullptr)) m_flags.set(D3D9DeviceFlag::DirtyFramebuffer); m_flags.set(D3D9DeviceFlag::DirtyDepthStencilState); break; - case D3DRS_ZENABLE: case D3DRS_ZFUNC: case D3DRS_TWOSIDEDSTENCILMODE: - case D3DRS_STENCILENABLE: case D3DRS_STENCILFAIL: case D3DRS_STENCILZFAIL: case D3DRS_STENCILPASS: @@ -5560,7 +5560,10 @@ namespace dxvk { m_state.renderTargets[i]->GetRenderTargetLayout() }; } - if (m_state.depthStencil != nullptr) { + if (m_state.depthStencil != nullptr && + (m_state.renderStates[D3DRS_ZENABLE] + || m_state.renderStates[D3DRS_ZWRITEENABLE] + || m_state.renderStates[D3DRS_STENCILENABLE])) { const DxvkImageCreateInfo& dsImageInfo = m_state.depthStencil->GetCommonTexture()->GetImage()->info(); const bool depthWrite = m_state.renderStates[D3DRS_ZWRITEENABLE];