1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[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.
This commit is contained in:
Robin Kertels 2023-06-21 15:56:35 +02:00 committed by Joshie
parent a287566c65
commit a20869fb93

View File

@ -5539,19 +5539,19 @@ namespace dxvk {
} }
if (unlikely(combinedUsage & D3DUSAGE_RENDERTARGET)) if (unlikely(combinedUsage & D3DUSAGE_RENDERTARGET))
UpdateActiveHazardsRT(UINT32_MAX); UpdateActiveHazardsRT(bit);
if (unlikely(combinedUsage & D3DUSAGE_DEPTHSTENCIL)) if (unlikely(combinedUsage & D3DUSAGE_DEPTHSTENCIL))
UpdateActiveHazardsDS(bit); UpdateActiveHazardsDS(bit);
} }
inline void D3D9DeviceEx::UpdateActiveHazardsRT(uint32_t rtMask) { inline void D3D9DeviceEx::UpdateActiveHazardsRT(uint32_t texMask) {
auto masks = m_psShaderMasks; auto masks = m_psShaderMasks;
masks.rtMask &= m_activeRTs & rtMask; masks.rtMask &= m_activeRTs;
masks.samplerMask &= m_activeRTTextures; 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 rtIdx : bit::BitMask(masks.rtMask)) {
for (uint32_t samplerIdx : bit::BitMask(masks.samplerMask)) { for (uint32_t samplerIdx : bit::BitMask(masks.samplerMask)) {
D3D9Surface* rtSurf = m_state.renderTargets[rtIdx].ptr(); D3D9Surface* rtSurf = m_state.renderTargets[rtIdx].ptr();
@ -5567,7 +5567,7 @@ namespace dxvk {
if (likely(rtSurf->GetMipLevel() != 0 || rtBase != texBase)) if (likely(rtSurf->GetMipLevel() != 0 || rtBase != texBase))
continue; continue;
m_activeHazardsRT |= 1 << rtIdx; m_activeHazardsRT |= 1 << samplerIdx;
} }
} }
} }
@ -5600,9 +5600,9 @@ namespace dxvk {
VK_ACCESS_SHADER_READ_BIT); 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... // Guaranteed to not be nullptr...
auto tex = m_state.renderTargets[rtIdx]->GetCommonTexture(); auto tex = GetCommonTexture(m_state.textures[samplerIdx]);
if (unlikely(!tex->MarkHazardous())) { if (unlikely(!tex->MarkHazardous())) {
TransitionImage(tex, m_hazardLayout); TransitionImage(tex, m_hazardLayout);
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer); m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);