1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-04 10:25:17 +02:00

[dxvk] Don't hold queue lock when invoking periodic memory tasks

This commit is contained in:
Philip Rebohle 2025-02-14 14:34:33 +01:00
parent 9573c389de
commit 6d9e0baa27

View File

@ -129,21 +129,23 @@ namespace dxvk {
void DxvkSubmissionQueue::submitCmdLists() {
env::setThreadName("dxvk-submit");
std::unique_lock<dxvk::mutex> 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<dxvk::mutex> 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<dxvk::mutex>(m_mutex);
{ std::unique_lock<dxvk::mutex> 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();