From f3c320b490bad6c358f0505b36cb01ea6abb7988 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 2 Nov 2024 20:11:28 +0100 Subject: [PATCH] [dxvk] Fix broken sync in injectCsChunk --- src/dxvk/dxvk_cs.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dxvk/dxvk_cs.cpp b/src/dxvk/dxvk_cs.cpp index 6a6716ab..37ed9f14 100644 --- a/src/dxvk/dxvk_cs.cpp +++ b/src/dxvk/dxvk_cs.cpp @@ -120,22 +120,27 @@ namespace dxvk { { std::unique_lock lock(m_mutex); seq = ++m_chunksDispatched; m_chunksQueued.push_back(std::move(chunk)); + m_condOnAdd.notify_one(); } - m_condOnAdd.notify_one(); return seq; } void DxvkCsThread::injectChunk(DxvkCsChunkRef&& chunk, bool synchronize) { - std::unique_lock lock(m_mutex); + uint64_t timeline; - uint64_t timeline = ++m_chunksInjectedCount; - m_chunksInjected.push_back(std::move(chunk)); + { std::unique_lock lock(m_mutex); - m_condOnAdd.notify_one(); + timeline = ++m_chunksInjectedCount; + m_chunksInjected.push_back(std::move(chunk)); + + m_condOnAdd.notify_one(); + } if (synchronize) { + std::unique_lock lock(m_counterMutex); + m_condOnSync.wait(lock, [this, timeline] { return m_chunksInjectedComplete.load() >= timeline; });