@@ -54,9 +54,9 @@ SwapChainVkImpl::SwapChainVkImpl(IReferenceCounters* pRefCounters,
5454 CreateSurface ();
5555 CreateVulkanSwapChain ();
5656 InitBuffersAndViews ();
57- VkResult res = AcquireNextImage (pDeviceContextVk);
58- DEV_CHECK_ERR (res == VK_SUCCESS, " Failed to acquire next image for the newly created swap chain " );
59- ( void )res;
57+
58+ AcquireNextImage (pDeviceContextVk );
59+ // Note that the image may be immediately out of date.
6060
6161 FenceDesc FenceCI;
6262 FenceCI.Name = " Swap chain frame complete fence" ;
@@ -620,7 +620,7 @@ VkResult SwapChainVkImpl::AcquireNextImage(DeviceContextVkImpl* pDeviceCtxVk)
620620 RefCntAutoPtr<ManagedSemaphore>& ImageAcquiredSemaphore = m_ImageAcquiredSemaphores[m_SemaphoreIndex];
621621
622622 VkResult res = vkAcquireNextImageKHR (LogicalDevice.GetVkDevice (), m_VkSwapChain, UINT64_MAX, ImageAcquiredSemaphore->Get (), VK_NULL_HANDLE, &m_BackBufferIndex);
623- if (res == VK_SUCCESS)
623+ if (res == VK_SUCCESS || res == VK_SUBOPTIMAL_KHR )
624624 {
625625 // Next command in the device context must wait for the next image to be acquired.
626626 // Unlike fences or events, the act of waiting for a semaphore also unsignals that semaphore.
@@ -745,7 +745,7 @@ void SwapChainVkImpl::Present(Uint32 SyncInterval)
745745 }
746746#endif
747747 }
748- DEV_CHECK_ERR (res == VK_SUCCESS, " Failed to acquire next swap chain image " );
748+ // The image may still be out of date if the window keeps changing size
749749 }
750750}
751751
@@ -919,9 +919,8 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR
919919 // RecreateVulkanSwapchain() unbinds default FB
920920 RecreateVulkanSwapchain (pImmediateCtxVk);
921921
922- VkResult res = AcquireNextImage (pImmediateCtxVk);
923- DEV_CHECK_ERR (res == VK_SUCCESS, " Failed to acquire next image for the just resized swap chain" );
924- (void )res;
922+ AcquireNextImage (pImmediateCtxVk);
923+ // The image may be immediately out of date if the window keeps being resized
925924 }
926925 catch (const std::runtime_error&)
927926 {
0 commit comments