VideoBackends:Vulkan: Wait until we've confirmed a successful AcquireNextImage before marking semaphores used

This commit is contained in:
TellowKrinkle 2024-09-30 22:00:41 -05:00
parent 7e1a9490c0
commit a267c56412
2 changed files with 12 additions and 3 deletions

View File

@ -63,11 +63,18 @@ public:
// Returns the semaphore for the current command buffer, which can be used to ensure the
// swap chain image is ready before the command buffer executes.
// Once you've confirmed that the semaphore will be signalled this frame, call
// `MarkCurrentCommandBufferSemaphoreUsed`.
VkSemaphore GetCurrentCommandBufferSemaphore()
{
auto& resources = m_command_buffers[m_current_cmd_buffer];
resources.semaphore_used = true;
return resources.semaphore;
return m_command_buffers[m_current_cmd_buffer].semaphore;
}
// Marks the current command buffer's semaphore as used, so we'll wait on it in the next
// command buffer submission.
void MarkCurrentCommandBufferSemaphoreUsed()
{
m_command_buffers[m_current_cmd_buffer].semaphore_used = true;
}
// Ensure that the worker thread has submitted any previous command buffers and is idle.

View File

@ -498,6 +498,8 @@ VkResult SwapChain::AcquireNextImage()
g_command_buffer_mgr->GetCurrentCommandBufferSemaphore(),
VK_NULL_HANDLE, &m_current_swap_chain_image_index);
m_current_swap_chain_image_is_valid = res >= 0;
if (IsCurrentImageValid())
g_command_buffer_mgr->MarkCurrentCommandBufferSemaphoreUsed();
if (res != VK_SUCCESS && res != VK_ERROR_OUT_OF_DATE_KHR && res != VK_SUBOPTIMAL_KHR)
LOG_VULKAN_ERROR(res, "vkAcquireNextImageKHR failed: ");