From 6b60de2d310cc1c4351e6423d226aca47eb5e0a2 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 24 Jun 2023 03:41:31 +0100 Subject: [PATCH] [d3d9] Fix unbinding RTs Fixes a regression with 8560efa3c7c4dbdb8b9fcb6e0aed282b43781c56 in ND1. Also more optimized. --- src/d3d9/d3d9_device.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 52016039..4cc39399 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -3394,7 +3394,7 @@ namespace dxvk { if (shader != nullptr) { m_flags.set(D3D9DeviceFlag::DirtyFFPixelShader); - BindShader(GetCommonShader(shader)); + BindShader(newShader); newShaderMasks = newShader->GetShaderMask(); } else { @@ -3408,7 +3408,9 @@ namespace dxvk { // If we have any RTs we would have bound to the the FB // not in the new shader mask, mark the framebuffer as dirty // so we unbind them. - if (m_boundRTs & m_anyColorWrites & m_psShaderMasks.rtMask & (~newShaderMasks.rtMask)) + uint32_t oldUseMask = m_activeRTs & m_psShaderMasks.rtMask; + uint32_t newUseMask = m_activeRTs & newShaderMasks.rtMask; + if (oldUseMask != newUseMask) m_flags.set(D3D9DeviceFlag::DirtyFramebuffer); if (m_psShaderMasks.samplerMask != newShaderMasks.samplerMask ||