From f113bcf199696ff1e5bd836c0e20cf84cc175509 Mon Sep 17 00:00:00 2001 From: Tyler Chatow Date: Fri, 16 May 2025 13:46:02 -0700 Subject: [PATCH] Fix segfault when maxImageCount is 0 When VkSurfaceCapabilitiesKHR.maxImageCount is 0, there is no limit on the number of images. This was being treated as a limit of 0. Signed-off-by: Tyler Chatow --- nvvkhl/app_swapchain_vk.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvvkhl/app_swapchain_vk.cpp b/nvvkhl/app_swapchain_vk.cpp index 544a370c..67ef8612 100644 --- a/nvvkhl/app_swapchain_vk.cpp +++ b/nvvkhl/app_swapchain_vk.cpp @@ -123,7 +123,10 @@ VkExtent2D nvvkhl::AppSwapchain::initResources(bool vSync /*= true*/) // Set the window size according to the surface's current extent outWindowSize = capabilities2.surfaceCapabilities.currentExtent; // Set the number of images in flight, respecting GPU limitations - m_maxFramesInFlight = std::min(m_maxFramesInFlight, capabilities2.surfaceCapabilities.maxImageCount); + if (capabilities2.surfaceCapabilities.maxImageCount > 0) + { + m_maxFramesInFlight = std::min(m_maxFramesInFlight, capabilities2.surfaceCapabilities.maxImageCount); + } // Store the chosen image format m_imageFormat = surfaceFormat2.surfaceFormat.format;