From 80fb7e2294768e47af1a84ccd47d93dfbed839bb Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 5 Feb 2025 19:43:08 +0100 Subject: [PATCH] [d3d9,d3d11] Adjust flush heuristic on tiling GPUs Probably needs work, just disable most of the heuristic for the time being. --- src/d3d11/d3d11_context_imm.cpp | 14 +++++++++++++- src/d3d11/d3d11_context_imm.h | 4 ++++ src/d3d9/d3d9_device.cpp | 12 +++++++++++- src/d3d9/d3d9_device.h | 2 ++ src/util/util_flush.cpp | 7 +++---- src/util/util_flush.h | 5 ++--- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 31426c850..90497b1e3 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -18,7 +18,7 @@ namespace dxvk { : D3D11CommonContext(pParent, Device, 0, DxvkCsChunkFlag::SingleUse), m_csThread(Device, Device->createContext()), m_submissionFence(new sync::CallbackFence()), - m_flushTracker(pParent->GetOptions()->reproducibleCommandStream), + m_flushTracker(GetMaxFlushType(pParent, Device)), m_stagingBufferFence(new sync::Fence(0)), m_multithread(this, false, pParent->GetOptions()->enableContextLock), m_videoContext(this, Device) { @@ -1074,4 +1074,16 @@ namespace dxvk { return stats; } + + GpuFlushType D3D11ImmediateContext::GetMaxFlushType( + D3D11Device* pParent, + const Rc& Device) { + if (pParent->GetOptions()->reproducibleCommandStream) + return GpuFlushType::ExplicitFlush; + else if (Device->perfHints().preferRenderPassOps) + return GpuFlushType::ImplicitStrongHint; + else + return GpuFlushType::ImplicitWeakHint; + } + } diff --git a/src/d3d11/d3d11_context_imm.h b/src/d3d11/d3d11_context_imm.h index 4bf35f83d..ca4fc5670 100644 --- a/src/d3d11/d3d11_context_imm.h +++ b/src/d3d11/d3d11_context_imm.h @@ -208,6 +208,10 @@ namespace dxvk { DxvkStagingBufferStats GetStagingMemoryStatistics(); + static GpuFlushType GetMaxFlushType( + D3D11Device* pParent, + const Rc& Device); + }; } diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index bea0e9201..99d5bd3bf 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -58,7 +58,7 @@ namespace dxvk { , m_csThread ( dxvkDevice, dxvkDevice->createContext() ) , m_csChunk ( AllocCsChunk() ) , m_submissionFence ( new sync::Fence() ) - , m_flushTracker ( m_d3d9Options.reproducibleCommandStream ) + , m_flushTracker ( GetMaxFlushType() ) , m_d3d9Interop ( this ) , m_d3d9On12 ( this ) , m_d3d8Bridge ( this ) { @@ -8731,4 +8731,14 @@ namespace dxvk { m_flags.clr(D3D9DeviceFlag::DirtySpecializationEntries); } + + GpuFlushType D3D9DeviceEx::GetMaxFlushType() const { + if (m_d3d9Options.reproducibleCommandStream) + return GpuFlushType::ExplicitFlush; + else if (m_dxvkDevice->perfHints().preferRenderPassOps) + return GpuFlushType::ImplicitStrongHint; + else + return GpuFlushType::ImplicitWeakHint; + } + } diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index ed86bb85e..cec35f3d4 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1397,6 +1397,8 @@ namespace dxvk { && !m_state.renderTargets[Index]->IsNull(); } + GpuFlushType GetMaxFlushType() const; + Com m_parent; D3DDEVTYPE m_deviceType; HWND m_window; diff --git a/src/util/util_flush.cpp b/src/util/util_flush.cpp index c2b1ce6a6..62315b826 100644 --- a/src/util/util_flush.cpp +++ b/src/util/util_flush.cpp @@ -2,9 +2,8 @@ namespace dxvk { - GpuFlushTracker::GpuFlushTracker( - bool ensureReproducibleHeuristic) - : m_ensureReproducibleHeuristic(ensureReproducibleHeuristic) { + GpuFlushTracker::GpuFlushTracker(GpuFlushType maxType) + : m_maxType(maxType) { } @@ -23,7 +22,7 @@ namespace dxvk { if (!chunkCount) return false; - if (m_ensureReproducibleHeuristic && flushType != GpuFlushType::ExplicitFlush) + if (flushType > m_maxType) return false; // Take any earlier missed flush with a stronger hint into account, so diff --git a/src/util/util_flush.h b/src/util/util_flush.h index c3e71ebcb..d5c4957cf 100644 --- a/src/util/util_flush.h +++ b/src/util/util_flush.h @@ -34,7 +34,7 @@ namespace dxvk { public: - GpuFlushTracker(bool ensureReproducibleHeuristic); + GpuFlushTracker(GpuFlushType maxAllowed); /** * \brief Checks whether a context flush should be performed @@ -63,8 +63,7 @@ namespace dxvk { private: - bool m_ensureReproducibleHeuristic; - + GpuFlushType m_maxType = GpuFlushType::ImplicitWeakHint; GpuFlushType m_lastMissedType = GpuFlushType::ImplicitWeakHint; uint64_t m_lastFlushChunkId = 0ull;