Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86430

Validation error when VulkanWindow creates swapchain



    • Bug
    • Status: Closed
    • P3: Somewhat important
    • Resolution: Done
    • 5.15.0
    • 5.15.3, 6.0.1
    • GUI: Vulkan
    • None


      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://github.com/KhronosGroup/Vulkan-Docs/search?q=)VUID-VkSwapchainCreateInfoKHR-minImageCount-01271)

      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;
          if (surfaceCaps.maxImageCount)
              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:



        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            lagocs Laszlo Agocs
            lukas_p Lucas P
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes