From a432befa8da63e92c72b0b546c0ea62612cfe06f Mon Sep 17 00:00:00 2001
From: Joshua Ashton <joshua@froggi.es>
Date: Mon, 9 Mar 2020 00:23:22 +0000
Subject: [PATCH] [d3d9] Add RT suffix to current hazard tracking

We can have DS hazards...
---
 src/d3d9/d3d9_device.cpp | 16 ++++++++--------
 src/d3d9/d3d9_device.h   |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp
index 211c3854f..103c39ae9 100644
--- a/src/d3d9/d3d9_device.cpp
+++ b/src/d3d9/d3d9_device.cpp
@@ -3016,7 +3016,7 @@ namespace dxvk {
       m_psShaderMasks = FixedFunctionMask;
     }
 
-    UpdateActiveHazards();
+    UpdateActiveHazardsRT();
 
     return D3D_OK;
   }
@@ -4710,7 +4710,7 @@ namespace dxvk {
         m_state.renderStates[ColorWriteIndex(index)])
       m_activeRTs |= bit;
 
-    UpdateActiveHazards();
+    UpdateActiveHazardsRT();
   }
 
 
@@ -4732,16 +4732,16 @@ namespace dxvk {
         m_activeTexturesToUpload |= bit;
     }
 
-    UpdateActiveHazards();
+    UpdateActiveHazardsRT();
   }
 
 
-  inline void D3D9DeviceEx::UpdateActiveHazards() {
+  inline void D3D9DeviceEx::UpdateActiveHazardsRT() {
     auto masks = m_psShaderMasks;
     masks.rtMask      &= m_activeRTs;
     masks.samplerMask &= m_activeRTTextures;
 
-    m_activeHazards = 0;
+    m_activeHazardsRT = 0;
     for (uint32_t rt = masks.rtMask; rt; rt &= rt - 1) {
       for (uint32_t sampler = masks.samplerMask; sampler; sampler &= sampler - 1) {
         D3D9Surface* rtSurf = m_state.renderTargets[bit::tzcnt(rt)].ptr();
@@ -4757,14 +4757,14 @@ namespace dxvk {
         if (likely(rtSurf->GetMipLevel() != 0 || rtBase != texBase))
           continue;
 
-        m_activeHazards |= 1 << bit::tzcnt(rt);
+        m_activeHazardsRT |= 1 << bit::tzcnt(rt);
       }
     }
   }
 
 
   void D3D9DeviceEx::MarkRenderHazards() {
-    for (uint32_t rt = m_activeHazards; rt; rt &= rt - 1) {
+    for (uint32_t rt = m_activeHazardsRT; rt; rt &= rt - 1) {
       // Guaranteed to not be nullptr...
       auto tex = m_state.renderTargets[bit::tzcnt(rt)]->GetCommonTexture();
       if (unlikely(!tex->MarkHazardous())) {
@@ -5435,7 +5435,7 @@ namespace dxvk {
 
 
   void D3D9DeviceEx::PrepareDraw(D3DPRIMITIVETYPE PrimitiveType) {
-    if (unlikely(m_activeHazards != 0)) {
+    if (unlikely(m_activeHazardsRT != 0)) {
       EmitCs([](DxvkContext* ctx) {
         ctx->emitRenderTargetReadbackBarrier();
       });
diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h
index bff6d118d..270ba2904 100644
--- a/src/d3d9/d3d9_device.h
+++ b/src/d3d9/d3d9_device.h
@@ -742,7 +742,7 @@ namespace dxvk {
 
     void UpdateActiveTextures(uint32_t index);
 
-    void UpdateActiveHazards();
+    void UpdateActiveHazardsRT();
 
     void MarkRenderHazards();
 
@@ -1028,7 +1028,7 @@ namespace dxvk {
 
     uint32_t                        m_activeRTs        = 0;
     uint32_t                        m_activeRTTextures = 0;
-    uint32_t                        m_activeHazards    = 0;
+    uint32_t                        m_activeHazardsRT  = 0;
     uint32_t                        m_alphaSwizzleRTs  = 0;
     uint32_t                        m_activeTextures   = 0;
     uint32_t                        m_activeTexturesToUpload = 0;