diff --git a/src/dxvk/dxvk_queue.cpp b/src/dxvk/dxvk_queue.cpp index c4eac35fa..6d2d153b6 100644 --- a/src/dxvk/dxvk_queue.cpp +++ b/src/dxvk/dxvk_queue.cpp @@ -129,21 +129,23 @@ namespace dxvk { void DxvkSubmissionQueue::submitCmdLists() { env::setThreadName("dxvk-submit"); - std::unique_lock lock(m_mutex); - uint64_t trackedSubmitId = 0u; uint64_t trackedPresentId = 0u; while (!m_stopped.load()) { - m_appendCond.wait(lock, [this] { - return m_stopped.load() || !m_submitQueue.empty(); - }); - - if (m_stopped.load()) - return; - - DxvkSubmitEntry entry = std::move(m_submitQueue.front()); - lock.unlock(); + DxvkSubmitEntry entry; + + { std::unique_lock lock(m_mutex); + + m_appendCond.wait(lock, [this] { + return m_stopped.load() || !m_submitQueue.empty(); + }); + + if (m_stopped.load()) + return; + + entry = std::move(m_submitQueue.front()); + } // Submit command buffer to device if (m_lastError != VK_ERROR_DEVICE_LOST) { @@ -191,24 +193,25 @@ namespace dxvk { entry.status->result = entry.result; // On success, pass it on to the queue thread - lock = std::unique_lock(m_mutex); + { std::unique_lock lock(m_mutex); - bool doForward = (entry.result == VK_SUCCESS) || - (entry.present.presenter != nullptr && entry.result != VK_ERROR_DEVICE_LOST); + bool doForward = (entry.result == VK_SUCCESS) || + (entry.present.presenter != nullptr && entry.result != VK_ERROR_DEVICE_LOST); - if (doForward) { - m_finishQueue.push(std::move(entry)); - } else { - Logger::err(str::format("DxvkSubmissionQueue: Command submission failed: ", entry.result)); - m_lastError = entry.result; + if (doForward) { + m_finishQueue.push(std::move(entry)); + } else { + Logger::err(str::format("DxvkSubmissionQueue: Command submission failed: ", entry.result)); + m_lastError = entry.result; - if (m_lastError != VK_ERROR_DEVICE_LOST) - m_device->waitForIdle(); + if (m_lastError != VK_ERROR_DEVICE_LOST) + m_device->waitForIdle(); + } + + m_submitQueue.pop(); + m_submitCond.notify_all(); } - m_submitQueue.pop(); - m_submitCond.notify_all(); - // Good time to invoke allocator tasks now since we // expect this to get called somewhat periodically. m_device->m_objects.memoryManager().performTimedTasks();