changeset 953:a540a64b6990

fix: swapchain recreating had a bug
author sam <sam@basx.dev>
date Mon, 01 Apr 2024 00:48:50 +0700
parents 4692be6e07eb
children 53249d9bb7a3
files semicongine/renderer.nim semicongine/vulkan/commandbuffer.nim
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
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")
--- a/semicongine/vulkan/commandbuffer.nim	Mon Apr 01 00:34:34 2024 +0700
+++ b/semicongine/vulkan/commandbuffer.nim	Mon Apr 01 00:48:50 2024 +0700
@@ -82,7 +82,6 @@
     commandBufferPool.destroy()
 
 
-
 proc destroy*(commandpool: var CommandBufferPool) =
   assert commandpool.device.vk.valid
   assert commandpool.vk.valid