diff options
author | Joshua Ashton <joshua@froggi.es> | 2020-04-09 18:09:11 +0300 |
---|---|---|
committer | Joshua Ashton <joshua@froggi.es> | 2020-04-09 18:15:39 +0300 |
commit | f28b777e6c769e818dc5e0b7739403e3e799de5c (patch) | |
tree | 94d939820bd2476e986de365b8e95e6fb1584acb | |
parent | 64b61067b0b7fb9712d148f7b0fca1aa68dcd91a (diff) |
[d3d9] Optimize hazard tracking in the SetTexture cased3d9-hazard-fix
We don't need to perform DS/RT hazard tracking updates if the texture we replaced and ourselves do not have those usages.
-rw-r--r-- | src/d3d9/d3d9_device.cpp | 19 | ||||
-rw-r--r-- | src/d3d9/d3d9_device.h | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 25a05736..d443ee51 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -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); } diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 4cd20a9e..aa7d48cd 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -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); |