VideoBackends:Vulkan: Wait until we've confirmed a successful AcquireNextImage before marking semaphores used
This commit is contained in:
parent
7e1a9490c0
commit
a267c56412
|
@ -63,11 +63,18 @@ public:
|
||||||
|
|
||||||
// Returns the semaphore for the current command buffer, which can be used to ensure the
|
// 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.
|
// 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()
|
VkSemaphore GetCurrentCommandBufferSemaphore()
|
||||||
{
|
{
|
||||||
auto& resources = m_command_buffers[m_current_cmd_buffer];
|
return m_command_buffers[m_current_cmd_buffer].semaphore;
|
||||||
resources.semaphore_used = true;
|
}
|
||||||
return resources.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.
|
// Ensure that the worker thread has submitted any previous command buffers and is idle.
|
||||||
|
|
|
@ -498,6 +498,8 @@ VkResult SwapChain::AcquireNextImage()
|
||||||
g_command_buffer_mgr->GetCurrentCommandBufferSemaphore(),
|
g_command_buffer_mgr->GetCurrentCommandBufferSemaphore(),
|
||||||
VK_NULL_HANDLE, &m_current_swap_chain_image_index);
|
VK_NULL_HANDLE, &m_current_swap_chain_image_index);
|
||||||
m_current_swap_chain_image_is_valid = res >= 0;
|
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)
|
if (res != VK_SUCCESS && res != VK_ERROR_OUT_OF_DATE_KHR && res != VK_SUBOPTIMAL_KHR)
|
||||||
LOG_VULKAN_ERROR(res, "vkAcquireNextImageKHR failed: ");
|
LOG_VULKAN_ERROR(res, "vkAcquireNextImageKHR failed: ");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue