vkGetSwapchainImagesKHR returns 5 images even if asked the minimum (3)
In the comments for one of our blogposts [1] it was mentioned the problem described. Quoting a little:
- Initial user comment:
What’s interesting is the minimum swap chain image count is 3, max is 0 but vkGetSwapchainImagesKHR returns 5.
- Question:
After a quick skim, 3 and 0 are just the min and maximum (0 for as many as memory allows), and 5 seems just the number returned by default. Having said so… > Swap chain image count doesn’t match! (3 / 5) … this seems a message from your engine. Does that mean that you specifically asked for the minimum, and you still got 5?
- Answer from the user:
Yes. By default I set the VkSwapchainCreateInfoKHR minImageCount to the minimum but I get 5 back. m_swapchainInfo.minImageCount = surfCapabilities.minImageCount; Running my engine on my gaming PC (and other PCs) will return the same swap chain image count as the minimum. I see a similar behavior when running my engine on Android. It will have a minimum of 2 but return 3. It’s that difference that inspired me to add the check.
It is true that's seem strange, but I would need to check the spec for that. So writing down this as an issue to not forget. Also, @itoral perhaps you already know the answer for this?
[1] https://blogs.igalia.com/apinheiro/2020/06/v3dv-quick-guide-to-build-and-run-some-demos/#comments