From 072d3a039e191d925771bd418fdde6f483f7e54c Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 24 Jul 2021 21:26:26 +0100 Subject: [PATCH] [d3d9] Track bound RTs This also improves active RT hazard tracking by also accounting for NULL --- src/d3d9/d3d9_device.cpp | 14 +++++++++++++- src/d3d9/d3d9_device.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index aebfa79f..25e665c2 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -1255,6 +1255,7 @@ namespace dxvk { m_state.renderTargets[RenderTargetIndex] = rt; + UpdateBoundRTs(RenderTargetIndex); UpdateActiveRTs(RenderTargetIndex); uint32_t originalAlphaSwizzleRTs = m_alphaSwizzleRTs; @@ -5000,12 +5001,23 @@ namespace dxvk { } + inline void D3D9DeviceEx::UpdateBoundRTs(uint32_t index) { + const uint32_t bit = 1 << index; + + m_boundRTs &= ~bit; + + if (m_state.renderTargets[index] != nullptr && + !m_state.renderTargets[index]->IsNull()) + m_boundRTs |= bit; + } + + inline void D3D9DeviceEx::UpdateActiveRTs(uint32_t index) { const uint32_t bit = 1 << index; m_activeRTs &= ~bit; - if (m_state.renderTargets[index] != nullptr && + if ((m_boundRTs & bit) != 0 && m_state.renderTargets[index]->GetBaseTexture() != nullptr && m_state.renderStates[ColorWriteIndex(index)]) m_activeRTs |= bit; diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 573bc15a..c2adec34 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -738,6 +738,8 @@ namespace dxvk { void Flush(); + void UpdateBoundRTs(uint32_t index); + void UpdateActiveRTs(uint32_t index); void UpdateActiveTextures(uint32_t index, DWORD combinedUsage); @@ -1050,6 +1052,7 @@ namespace dxvk { uint32_t m_activeTextures = 0; uint32_t m_activeTexturesToUpload = 0; uint32_t m_activeTexturesToGen = 0; + uint32_t m_boundRTs = 0; uint32_t m_fetch4Enabled = 0; uint32_t m_fetch4 = 0;