From 89c3b60640b9fe342b71f6ae8d89fa600fe55aa2 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 3 Apr 2018 20:06:25 +0200 Subject: [PATCH] [dxvk] Removed upper limit for CS chunks Since we are synchronizing once per frame anyway, there is no need to artificially limit the number of chunks in flight. Applications which use deferred contexts and submit a large number of CS chunks through command lists may benefit from this optimization. --- src/dxvk/dxvk_cs.cpp | 20 +++++++------------- src/dxvk/dxvk_cs.h | 4 +--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/dxvk/dxvk_cs.cpp b/src/dxvk/dxvk_cs.cpp index 4aef3ea07..c6428a9f9 100644 --- a/src/dxvk/dxvk_cs.cpp +++ b/src/dxvk/dxvk_cs.cpp @@ -53,15 +53,9 @@ namespace dxvk { void DxvkCsThread::dispatchChunk(Rc&& chunk) { - std::unique_lock lock(m_mutex); - m_chunksPending += 1; - m_chunksQueued.push(std::move(chunk)); - - if (m_chunksPending > MaxChunksInFlight) { - m_condOnSync.wait(lock, [this] { - return (m_chunksPending <= MaxChunksInFlight ) - || (m_stopped.load()); - }); + { std::unique_lock lock(m_mutex); + m_chunksQueued.push(std::move(chunk)); + m_chunksPending += 1; } m_condOnAdd.notify_one(); @@ -83,8 +77,10 @@ namespace dxvk { while (!m_stopped.load()) { { std::unique_lock lock(m_mutex); if (chunk != nullptr) { - m_chunksPending -= 1; - m_condOnSync.notify_one(); + if (--m_chunksPending == 0) + m_condOnSync.notify_one(); + + chunk = nullptr; } if (m_chunksQueued.size() == 0) { @@ -97,8 +93,6 @@ namespace dxvk { if (m_chunksQueued.size() != 0) { chunk = std::move(m_chunksQueued.front()); m_chunksQueued.pop(); - } else { - chunk = nullptr; } } diff --git a/src/dxvk/dxvk_cs.h b/src/dxvk/dxvk_cs.h index a1b32d826..6ab79d77e 100644 --- a/src/dxvk/dxvk_cs.h +++ b/src/dxvk/dxvk_cs.h @@ -166,9 +166,7 @@ namespace dxvk { * commands on a DXVK context. */ class DxvkCsThread { - // Limit the number of chunks in the queue - // to prevent memory leaks, stuttering etc. - constexpr static uint32_t MaxChunksInFlight = 32; + public: DxvkCsThread(const Rc& context);