1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[d3d9] Optimize hazard tracking in the SetTexture case

We don't need to perform DS/RT hazard tracking updates if the texture we replaced and ourselves do not have those usages.
This commit is contained in:
Joshua Ashton 2020-04-09 16:09:11 +01:00 committed by Joshie
parent 9b4cd8aa87
commit 6e5e50c359
2 changed files with 16 additions and 5 deletions

View File

@ -3527,12 +3527,20 @@ namespace dxvk {
// a valid resource or vice versa.
if (pTexture == nullptr || m_state.textures[StateSampler] == nullptr)
m_flags.set(D3D9DeviceFlag::DirtyFFPixelShader);
auto oldTexture = GetCommonTexture(m_state.textures[StateSampler]);
auto newTexture = GetCommonTexture(pTexture);
DWORD oldUsage = oldTexture != nullptr ? oldTexture->Desc()->Usage : 0;
DWORD newUsage = newTexture != nullptr ? newTexture->Desc()->Usage : 0;
DWORD combinedUsage = oldUsage | newUsage;
TextureChangePrivate(m_state.textures[StateSampler], pTexture);
BindTexture(StateSampler);
UpdateActiveTextures(StateSampler);
UpdateActiveTextures(StateSampler, combinedUsage);
return D3D_OK;
}
@ -4718,7 +4726,7 @@ namespace dxvk {
}
inline void D3D9DeviceEx::UpdateActiveTextures(uint32_t index) {
inline void D3D9DeviceEx::UpdateActiveTextures(uint32_t index, DWORD combinedUsage) {
const uint32_t bit = 1 << index;
m_activeRTTextures &= ~bit;
@ -4740,8 +4748,11 @@ namespace dxvk {
m_activeTexturesToUpload |= bit;
}
UpdateActiveHazardsRT(UINT32_MAX);
UpdateActiveHazardsDS(bit);
if (unlikely(combinedUsage & D3DUSAGE_RENDERTARGET))
UpdateActiveHazardsRT(UINT32_MAX);
if (unlikely(combinedUsage & D3DUSAGE_DEPTHSTENCIL))
UpdateActiveHazardsDS(bit);
}

View File

@ -740,7 +740,7 @@ namespace dxvk {
void UpdateActiveRTs(uint32_t index);
void UpdateActiveTextures(uint32_t index);
void UpdateActiveTextures(uint32_t index, DWORD combinedUsage);
void UpdateActiveHazardsRT(uint32_t rtMask);