I've worked through the vulkan-tutorial.com tutorial and tried to write a small program with Vulkan, but I came across the following problem:
The program simply displays an image and runs without errors, but after the size of the window is changed, and thus the swapchain etc. recreated, a validation layer throws an error message in the vkQueuePresentKHR function:
Validation layer: [ VUID-VkPresentInfoKHR-pImageIndices-01296 ] Object: 0x4e3b5f0 (Type = 4) | Images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_UNDEFINED. The Vulkan spec states: Each element of pImageIndices must be the index of a presentable image acquired from the swapchain specified by the corresponding element of the pSwapchains array, and the presented image subresource must be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout at the time the operation is executed on a VkDevice (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkPresentInfoKHR-pImageIndices-01296)
This error message does not occur, once or twice, when the swapchain and all other objects that depend on the window size have been recreated and vkQueuePresentKHR has been called.
Why can the swapchain's images be in the wrong layout for a short time and be back in the right layout after a maximum of two loop passes?