diff semicongine/renderer.nim @ 953:a540a64b6990

fix: swapchain recreating had a bug
author sam <sam@basx.dev>
date Mon, 01 Apr 2024 00:48:50 +0700
parents c6213a794ab0
children cca6f1a675db
line wrap: on
line diff
--- a/semicongine/renderer.nim	Mon Apr 01 00:34:34 2024 +0700
+++ b/semicongine/renderer.nim	Mon Apr 01 00:48:50 2024 +0700
@@ -413,8 +413,9 @@
   scene.clearDirtyShaderGlobals()
 
 proc startNewFrame*(renderer: var Renderer) =
-  # this is kinda important as we will wait for the queue finished fence from the swapchain
-  if not renderer.swapchain.acquireNextFrame():
+  # TODO: chance for an infinity-loop
+  while not renderer.swapchain.acquireNextFrame():
+    checkVkResult renderer.device.vk.vkDeviceWaitIdle()
     let res = renderer.swapchain.recreate()
     if not res.isSome:
       raise newException(Exception, "Unable to recreate swapchain")