rendervulkan: ensure queue is idle before swapchain recreation

The CVulkanDevice::waitIdle call at the beginning of
vulkan_remake_swapchain only waits for the most recently submitted
command buffer to complete. This is inadequate because it does not wait
for any additional commands which may have been submitted by the driver
during vkQueuePresentKHR.  Such commands could reference resources
associated with the old swapchain, so it is not safe to destroy it until
they are also complete.

To fix the issue, instead of calling CVulkanDevice::waitIdle,
vulkan_remake_swapchain will call vkQueueWaitIdle.

Fixes: #945

Co-authored-by: Erik Kurzinger <ekurzinger@nvidia.com>
This commit is contained in:
Joshua Ashton 2023-09-14 18:53:38 +01:00
parent ae73dd1ce0
commit af3f6bf827
2 changed files with 2 additions and 0 deletions

View file

@ -2694,6 +2694,7 @@ bool vulkan_remake_swapchain( void )
{ {
VulkanOutput_t *pOutput = &g_output; VulkanOutput_t *pOutput = &g_output;
g_device.waitIdle(); g_device.waitIdle();
g_device.vk.QueueWaitIdle( g_device.queue() );
pOutput->outputImages.clear(); pOutput->outputImages.clear();

View file

@ -647,6 +647,7 @@ static inline uint32_t div_roundup(uint32_t x, uint32_t y)
VK_FUNC(MapMemory) \ VK_FUNC(MapMemory) \
VK_FUNC(QueuePresentKHR) \ VK_FUNC(QueuePresentKHR) \
VK_FUNC(QueueSubmit) \ VK_FUNC(QueueSubmit) \
VK_FUNC(QueueWaitIdle) \
VK_FUNC(ResetCommandBuffer) \ VK_FUNC(ResetCommandBuffer) \
VK_FUNC(ResetFences) \ VK_FUNC(ResetFences) \
VK_FUNC(UnmapMemory) \ VK_FUNC(UnmapMemory) \