From a20869fb93e2609594bf4fc37ddb2152c21ec150 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 21 Jun 2023 15:56:35 +0200 Subject: [PATCH] [d3d9] Track textures in m_activeHazardsRT instead of RT There's 21 textures and only 4 RTs. Tracking the textures allows us to mask off the active texture bitfield instead of the active render target one, potentially resulting in fewer iterations. --- src/d3d9/d3d9_device.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 02fa688b..0c844b0f 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -5539,19 +5539,19 @@ namespace dxvk { } if (unlikely(combinedUsage & D3DUSAGE_RENDERTARGET)) - UpdateActiveHazardsRT(UINT32_MAX); + UpdateActiveHazardsRT(bit); if (unlikely(combinedUsage & D3DUSAGE_DEPTHSTENCIL)) UpdateActiveHazardsDS(bit); } - inline void D3D9DeviceEx::UpdateActiveHazardsRT(uint32_t rtMask) { + inline void D3D9DeviceEx::UpdateActiveHazardsRT(uint32_t texMask) { auto masks = m_psShaderMasks; - masks.rtMask &= m_activeRTs & rtMask; - masks.samplerMask &= m_activeRTTextures; + masks.rtMask &= m_activeRTs; + masks.samplerMask &= m_activeRTTextures & texMask; - m_activeHazardsRT = m_activeHazardsRT & (~rtMask); + m_activeHazardsRT = m_activeHazardsRT & (~texMask); for (uint32_t rtIdx : bit::BitMask(masks.rtMask)) { for (uint32_t samplerIdx : bit::BitMask(masks.samplerMask)) { D3D9Surface* rtSurf = m_state.renderTargets[rtIdx].ptr(); @@ -5567,7 +5567,7 @@ namespace dxvk { if (likely(rtSurf->GetMipLevel() != 0 || rtBase != texBase)) continue; - m_activeHazardsRT |= 1 << rtIdx; + m_activeHazardsRT |= 1 << samplerIdx; } } } @@ -5600,9 +5600,9 @@ namespace dxvk { VK_ACCESS_SHADER_READ_BIT); }); - for (uint32_t rtIdx : bit::BitMask(m_activeHazardsRT)) { + for (uint32_t samplerIdx : bit::BitMask(m_activeHazardsRT)) { // Guaranteed to not be nullptr... - auto tex = m_state.renderTargets[rtIdx]->GetCommonTexture(); + auto tex = GetCommonTexture(m_state.textures[samplerIdx]); if (unlikely(!tex->MarkHazardous())) { TransitionImage(tex, m_hazardLayout); m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);