When QVulkanWindow creates its swapchain, the following validation error is reported:
vkDebug: Validation: 0: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-minImageCount-01271 ] Object 0: handle = 0x55957fa70cf0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xe18476f3 | vkCreateSwapchainKHR() called with minImageCount = 2, which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. minImageCount = 3, maxImageCount = 0). The Vulkan spec states: minImageCount must be greater than or equal to the value returned in the minImageCount member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https:
The validation error is outputted once when the window is created and again every time it is resized.
I was able to reproduce this validation error in the hellovulkanwindow example by adding the `VK_LAYER_KHRONOS_validation` layer to the Vulkan instance in main.cpp (line 68):
inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation" << "VK_LAYER_KHRONOS_validation");
I believe this error is from qtbase/src/gui/vulkan/qvulkanwindow.cpp in lines 1045-1049 (https://github.com/qt/qtbase/blob/dev/src/gui/vulkan/qvulkanwindow.cpp#L1048) (inside of QVulkanWindowPrivate::recreateSwapChain):
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physDev, surface, &surfaceCaps);
uint32_t reqBufferCount = swapChainBufferCount;
reqBufferCount = qBound(surfaceCaps.minImageCount, reqBufferCount, surfaceCaps.maxImageCount);
Adding the following line:
reqBufferCount = qMax(surfaceCaps.minImageCount, reqBufferCount);
Seems like it would solve the problem because right now if the maxImageCount is 0, the minImageCount is ignored when it shouldn't.
Relevant vulkan documentation: