# HG changeset patch # User Sam # Date 1683557147 -25200 # Node ID 24d18cd8be8a62c345b57f199c9b856a91a1f1b9 # Parent 6e2017cb8b8b23dc8267116faf066b73d51585bd did: try to simplfy swapchain recreation, not sure if it is a good idea diff -r 6e2017cb8b8b -r 24d18cd8be8a src/semicongine/renderer.nim --- a/src/semicongine/renderer.nim Mon May 08 21:23:29 2023 +0700 +++ b/src/semicongine/renderer.nim Mon May 08 21:45:47 2023 +0700 @@ -230,17 +230,15 @@ var commandBufferResult = renderer.swapchain.nextFrame() commandBuffer: VkCommandBuffer - oldSwapchain: Swapchain if not commandBufferResult.isSome: - oldSwapchain = renderer.swapchain let res = renderer.swapchain.recreate() if res.isSome: + var oldSwapchain = renderer.swapchain renderer.swapchain = res.get() - commandBufferResult = renderer.swapchain.nextFrame() - assert commandBufferResult.isSome - else: - raise newException(Exception, "Unable to recreate swapchain") + checkVkResult renderer.device.vk.vkDeviceWaitIdle() + oldSwapchain.destroy() + return commandBuffer = commandBufferResult.get() commandBuffer.beginRenderCommands(renderer.renderPass, renderer.swapchain.currentFramebuffer()) @@ -268,16 +266,12 @@ commandBuffer.endRenderCommands() if not renderer.swapchain.swap(): - oldSwapchain = renderer.swapchain let res = renderer.swapchain.recreate() if res.isSome: + var oldSwapchain = renderer.swapchain renderer.swapchain = res.get() - else: - raise newException(Exception, "Unable to recreate swapchain") - - if oldSwapchain.vk.valid: - checkVkResult renderer.device.vk.vkDeviceWaitIdle() - oldSwapchain.destroy() + checkVkResult renderer.device.vk.vkDeviceWaitIdle() + oldSwapchain.destroy() func framesRendered*(renderer: Renderer): uint64 = renderer.swapchain.framesRendered