From b1d4d5db5e07e201bb1211ab8f26ab3a462f0dbf Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 24 Jan 2021 17:30:29 +1000 Subject: [PATCH] Vulkan/SwapChain: Recreate semaphores when resizing Prevents us acquiring an image on an already-signaled semaphore. --- src/common/vulkan/swap_chain.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/vulkan/swap_chain.cpp b/src/common/vulkan/swap_chain.cpp index cb06a386a..754597f53 100644 --- a/src/common/vulkan/swap_chain.cpp +++ b/src/common/vulkan/swap_chain.cpp @@ -507,6 +507,7 @@ VkResult SwapChain::AcquireNextImage() bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 */) { + DestroySemaphores(); DestroySwapChainImages(); if (new_width != 0 && new_height != 0) @@ -515,7 +516,7 @@ bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 * m_wi.surface_height = new_height; } - if (!CreateSwapChain() || !SetupSwapChainImages()) + if (!CreateSwapChain() || !SetupSwapChainImages() || !CreateSemaphores()) { Panic("Failed to re-configure swap chain images, this is fatal (for now)"); return false; @@ -526,9 +527,10 @@ bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 * bool SwapChain::RecreateSwapChain() { + DestroySemaphores(); DestroySwapChainImages(); DestroySwapChain(); - if (!CreateSwapChain() || !SetupSwapChainImages()) + if (!CreateSwapChain() || !SetupSwapChainImages() || !CreateSemaphores()) { Panic("Failed to re-configure swap chain images, this is fatal (for now)"); return false; @@ -550,6 +552,7 @@ bool SwapChain::SetVSync(bool enabled) bool SwapChain::RecreateSurface(const WindowInfo& new_wi) { // Destroy the old swap chain, images, and surface. + DestroySemaphores(); DestroySwapChainImages(); DestroySwapChain(); DestroySurface(); @@ -577,7 +580,7 @@ bool SwapChain::RecreateSurface(const WindowInfo& new_wi) } // Finally re-create the swap chain - if (!CreateSwapChain() || !SetupSwapChainImages()) + if (!CreateSwapChain() || !SetupSwapChainImages() || !CreateSemaphores()) return false; return true;