summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp')
-rw-r--r--Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
index d8ef681b56..5c1df797c0 100644
--- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
+++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
@@ -239,6 +239,8 @@ bool CommandBufferManager::CreateSubmitThread()
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);
@@ -284,11 +286,16 @@ void CommandBufferManager::WaitForFenceCounter(u64 fence_counter)
void CommandBufferManager::WaitForCommandBufferCompletion(u32 index)
{
- // Ensure this command buffer has been submitted.
- WaitForWorkerThreadIdle();
-
CmdBufferResources& resources = m_command_buffers[index];
+ // Ensure this command buffer has been submitted.
+ if (resources.waiting_for_submit.load(std::memory_order_acquire))
+ {
+ WaitForWorkerThreadIdle();
+ ASSERT_MSG(VIDEO, !resources.waiting_for_submit.load(std::memory_order_relaxed),
+ "Submit thread is idle but command buffer is still waiting for submission!");
+ }
+
// Wait for this command buffer to be completed.
VkResult res =
vkWaitForFences(g_vulkan_context->GetDevice(), 1, &resources.fence, VK_TRUE, UINT64_MAX);
@@ -339,6 +346,7 @@ void CommandBufferManager::SubmitCommandBuffer(bool submit_on_worker_thread,
// Submitting off-thread?
if (m_use_threaded_submission && submit_on_worker_thread && !wait_for_completion)
{
+ resources.waiting_for_submit.store(true, std::memory_order_relaxed);
// Push to the pending submit queue.
{
std::lock_guard<std::mutex> guard(m_pending_submit_lock);