diff --git a/src/dxvk/dxvk_cs.cpp b/src/dxvk/dxvk_cs.cpp index 4aef3ea0..c6428a9f 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 a1b32d82..6ab79d77 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);