changeset 52:5ab7fb4d9ee9

fix: wrong number of swapchain images
author Sam <sam@basx.dev>
date Thu, 19 Jan 2023 17:39:32 +0700
parents 7684744ab1a4
children 4c3891eb9ef9
files src/semicongine/engine.nim
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/engine.nim	Thu Jan 19 17:00:06 2023 +0700
+++ b/src/semicongine/engine.nim	Thu Jan 19 17:39:32 2023 +0700
@@ -180,11 +180,13 @@
 
   let capabilities = physicalDevice.device.getSurfaceCapabilities(surface)
   var selectedPresentationMode = getPresentMode(physicalDevice.presentModes)
+  var imageCount = capabilities.minImageCount + 1
+  imageCount = max(min(capabilities.maxImageCount, imageCount), 1)
   # setup swapchain
   var swapchainCreateInfo = VkSwapchainCreateInfoKHR(
     sType: VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
     surface: surface,
-    minImageCount: max(capabilities.minImageCount + 1, capabilities.maxImageCount),
+    minImageCount: imageCount,
     imageFormat: surfaceFormat.format,
     imageColorSpace: surfaceFormat.colorSpace,
     imageExtent: dimension,