Description
In SwapChainVkImpl::SwapChainVkImpl
, we have the following code:
auto res = AcquireNextImage(pDeviceContextVk);
DEV_CHECK_ERR(res == VK_SUCCESS, "Failed to acquire next image for the newly created swap chain");
which, if this call to vkAcquireNextImageKHR
inside AcquireNextImage
auto res = vkAcquireNextImageKHR(LogicalDevice.GetVkDevice(), m_VkSwapChain, UINT64_MAX, ImageAcquiredSemaphore, ImageAcquiredFence, &m_BackBufferIndex);
m_ImageAcquiredFenceSubmitted[m_SemaphoreIndex] = (res == VK_SUCCESS);
if (res == VK_SUCCESS)
{
/* we never get here */
}
return res;
happens to return VK_ERROR_OUT_OF_DATE_KHR
, will immediately crash at the DEV_CHECK_ERR
. However, this error should be recoverable; https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkResult.html states
VK_ERROR_OUT_OF_DATE_KHR
A surface has changed in such a way that it is no longer compatible with the swapchain, and further presentation requests using the swapchain will fail. Applications must query the new surface properties and recreate their swapchain if they wish to continue presenting to the surface.
It would be great if, in the future, the Vulkan swapchain implementation could check for this error, and either try to recreate the swapchain, or propagate this error to the user and allow users to provide new parameters in a future call (or something along those lines that does not result in a crash). Right now, this sometimes fails on my first call to factoryVk->CreateSwapChainVk
on Ubuntu 24.04, which is problematic as it seems there is nothing I can without modifying Diligent code.