VideoBackends:Vulkan: Clean up submission thread BlockingLoop usage
This commit is contained in:
parent
002a96adb0
commit
9186050daa
|
@ -226,33 +226,25 @@ bool CommandBufferManager::CreateSubmitThread()
|
|||
Common::SetCurrentThreadName("Vulkan CommandBufferManager SubmitThread");
|
||||
|
||||
m_submit_loop->Run([this]() {
|
||||
PendingCommandBufferSubmit submit;
|
||||
while (true)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_submit_lock);
|
||||
if (m_pending_submits.empty())
|
||||
PendingCommandBufferSubmit submit;
|
||||
{
|
||||
m_submit_loop->AllowSleep();
|
||||
m_submit_worker_idle = true;
|
||||
m_submit_worker_condvar.notify_all();
|
||||
return;
|
||||
std::lock_guard<std::mutex> guard(m_pending_submit_lock);
|
||||
if (m_pending_submits.empty())
|
||||
{
|
||||
m_submit_loop->AllowSleep();
|
||||
return;
|
||||
}
|
||||
|
||||
submit = m_pending_submits.front();
|
||||
m_pending_submits.pop_front();
|
||||
}
|
||||
|
||||
submit = m_pending_submits.front();
|
||||
m_pending_submits.pop_front();
|
||||
}
|
||||
|
||||
SubmitCommandBuffer(submit.command_buffer_index, submit.present_swap_chain,
|
||||
submit.present_image_index);
|
||||
CmdBufferResources& resources = m_command_buffers[submit.command_buffer_index];
|
||||
resources.waiting_for_submit.store(false, std::memory_order_release);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_submit_lock);
|
||||
if (m_pending_submits.empty())
|
||||
{
|
||||
m_submit_worker_idle = true;
|
||||
m_submit_worker_condvar.notify_all();
|
||||
}
|
||||
SubmitCommandBuffer(submit.command_buffer_index, submit.present_swap_chain,
|
||||
submit.present_image_index);
|
||||
CmdBufferResources& resources = m_command_buffers[submit.command_buffer_index];
|
||||
resources.waiting_for_submit.store(false, std::memory_order_release);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -265,8 +257,7 @@ void CommandBufferManager::WaitForWorkerThreadIdle()
|
|||
if (!m_use_threaded_submission)
|
||||
return;
|
||||
|
||||
std::unique_lock lock{m_pending_submit_lock};
|
||||
m_submit_worker_condvar.wait(lock, [&] { return m_submit_worker_idle; });
|
||||
m_submit_loop->Wait();
|
||||
}
|
||||
|
||||
void CommandBufferManager::WaitForFenceCounter(u64 fence_counter)
|
||||
|
@ -354,12 +345,10 @@ void CommandBufferManager::SubmitCommandBuffer(bool submit_on_worker_thread,
|
|||
// Push to the pending submit queue.
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_submit_lock);
|
||||
m_submit_worker_idle = false;
|
||||
m_pending_submits.push_back({present_swap_chain, present_image_index, m_current_cmd_buffer});
|
||||
// Wake up the worker thread for a single iteration.
|
||||
m_submit_loop->Wakeup();
|
||||
}
|
||||
|
||||
// Wake up the worker thread for a single iteration.
|
||||
m_submit_loop->Wakeup();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -157,8 +157,6 @@ private:
|
|||
VkSemaphore m_present_semaphore = VK_NULL_HANDLE;
|
||||
std::deque<PendingCommandBufferSubmit> m_pending_submits;
|
||||
std::mutex m_pending_submit_lock;
|
||||
std::condition_variable m_submit_worker_condvar;
|
||||
bool m_submit_worker_idle = true;
|
||||
Common::Flag m_last_present_failed;
|
||||
Common::Flag m_last_present_done;
|
||||
VkResult m_last_present_result = VK_SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue