1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[d3d9] Optimize unnecessary loops in hazard tracking

We only want to update specific indices of bitfields at a time, so pass through that information and mask it off.
This commit is contained in:
Joshua Ashton 2020-03-09 00:49:32 +00:00
parent 812a113a85
commit e33627cfdc
2 changed files with 15 additions and 14 deletions

View File

@ -1235,7 +1235,7 @@ namespace dxvk {
m_state.depthStencil = ds; m_state.depthStencil = ds;
UpdateActiveHazardsDS(); UpdateActiveHazardsDS(UINT32_MAX);
return D3D_OK; return D3D_OK;
} }
@ -3018,7 +3018,7 @@ namespace dxvk {
m_psShaderMasks = FixedFunctionMask; m_psShaderMasks = FixedFunctionMask;
} }
UpdateActiveHazardsRT(); UpdateActiveHazardsRT(UINT32_MAX, UINT32_MAX);
return D3D_OK; return D3D_OK;
} }
@ -4712,7 +4712,7 @@ namespace dxvk {
m_state.renderStates[ColorWriteIndex(index)]) m_state.renderStates[ColorWriteIndex(index)])
m_activeRTs |= bit; m_activeRTs |= bit;
UpdateActiveHazardsRT(); UpdateActiveHazardsRT(bit, UINT32_MAX);
} }
@ -4738,17 +4738,17 @@ namespace dxvk {
m_activeTexturesToUpload |= bit; m_activeTexturesToUpload |= bit;
} }
UpdateActiveHazardsRT(); UpdateActiveHazardsRT(UINT32_MAX, bit);
UpdateActiveHazardsDS(); UpdateActiveHazardsDS(bit);
} }
inline void D3D9DeviceEx::UpdateActiveHazardsRT() { inline void D3D9DeviceEx::UpdateActiveHazardsRT(uint32_t rtMask, uint32_t texMask) {
auto masks = m_psShaderMasks; auto masks = m_psShaderMasks;
masks.rtMask &= m_activeRTs; masks.rtMask &= m_activeRTs & rtMask;
masks.samplerMask &= m_activeRTTextures; masks.samplerMask &= m_activeRTTextures & texMask;
m_activeHazardsRT = 0; m_activeHazardsRT = m_activeHazardsRT & (~rtMask);
for (uint32_t rt = masks.rtMask; rt; rt &= rt - 1) { for (uint32_t rt = masks.rtMask; rt; rt &= rt - 1) {
for (uint32_t sampler = masks.samplerMask; sampler; sampler &= sampler - 1) { for (uint32_t sampler = masks.samplerMask; sampler; sampler &= sampler - 1) {
const uint32_t rtIdx = bit::tzcnt(rt); const uint32_t rtIdx = bit::tzcnt(rt);
@ -4771,11 +4771,12 @@ namespace dxvk {
} }
inline void D3D9DeviceEx::UpdateActiveHazardsDS() { inline void D3D9DeviceEx::UpdateActiveHazardsDS(uint32_t texMask) {
m_activeHazardsDS = 0; m_activeHazardsDS = m_activeHazardsDS & (~texMask);
if (m_state.depthStencil != nullptr && if (m_state.depthStencil != nullptr &&
m_state.depthStencil->GetBaseTexture() != nullptr) { m_state.depthStencil->GetBaseTexture() != nullptr) {
for (uint32_t sampler = m_activeDSTextures; sampler; sampler &= sampler - 1) { uint32_t samplerMask = m_activeDSTextures & texMask;
for (uint32_t sampler = samplerMask; sampler; sampler &= sampler - 1) {
const uint32_t samplerIdx = bit::tzcnt(sampler); const uint32_t samplerIdx = bit::tzcnt(sampler);
IDirect3DBaseTexture9* dsBase = m_state.depthStencil->GetBaseTexture(); IDirect3DBaseTexture9* dsBase = m_state.depthStencil->GetBaseTexture();

View File

@ -742,9 +742,9 @@ namespace dxvk {
void UpdateActiveTextures(uint32_t index); void UpdateActiveTextures(uint32_t index);
void UpdateActiveHazardsRT(); void UpdateActiveHazardsRT(uint32_t rtMask, uint32_t texMask);
void UpdateActiveHazardsDS(); void UpdateActiveHazardsDS(uint32_t texMask);
void MarkRenderHazards(); void MarkRenderHazards();