From 5aa3b8d101bf157a5ec523bed26cf6783a3c4265 Mon Sep 17 00:00:00 2001 From: Etaash Mathamsetty Date: Tue, 19 Dec 2023 18:56:50 -0500 Subject: [PATCH] mantle/wsi: fix minImageCount --- src/mantle/mantle_wsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mantle/mantle_wsi.c b/src/mantle/mantle_wsi.c index 768509db..2fa65319 100644 --- a/src/mantle/mantle_wsi.c +++ b/src/mantle/mantle_wsi.c @@ -235,13 +235,21 @@ static void recreateSwapchain( GetClientRect(hwnd, &clientRect); const VkExtent2D imageExtent = { clientRect.right, clientRect.bottom }; + VkSurfaceCapabilitiesKHR surfaceCapabilities; + res = vki.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(grDevice->physicalDevice, mSurface, + &surfaceCapabilities); + if (res != VK_SUCCESS) { + LOGE("vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed (%d)\n", res); + return; + } + // Recreate swapchain const VkSwapchainCreateInfoKHR swapchainCreateInfo = { .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, .pNext = NULL, .flags = 0, .surface = mSurface, - .minImageCount = 3, + .minImageCount = MAX(3, surfaceCapabilities.minImageCount), .imageFormat = VK_FORMAT_B8G8R8A8_UNORM, .imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, .imageExtent = imageExtent,