# HG changeset patch # User sam # Date 1758726884 -25200 # Node ID a9c0f899a734fa6505f8529369f9a554bb3c7a27 # Parent 02e869aded5d5c2d9f246bbb66f3802c81b7b046 fix: issue with presentation-wait semaphores, this time FR diff -r 02e869aded5d -r a9c0f899a734 semicongine/core/types.nim --- a/semicongine/core/types.nim Wed Sep 24 21:57:52 2025 +0700 +++ b/semicongine/core/types.nim Wed Sep 24 22:14:44 2025 +0700 @@ -93,8 +93,8 @@ # frame-in-flight handling currentFiF*: range[0 .. (INFLIGHTFRAMES - 1).int] queueFinishedFence*: array[INFLIGHTFRAMES.int, VkFence] - imageAvailableSemaphore*: seq[VkSemaphore] - renderFinishedSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] + imageAvailableSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] + renderFinishedSemaphore*: seq[VkSemaphore] commandBuffers*: array[INFLIGHTFRAMES.int, VkCommandBuffer] oldSwapchain*: Swapchain oldSwapchainCounter*: int # swaps until old swapchain will be destroyed diff -r 02e869aded5d -r a9c0f899a734 semicongine/rendering/swapchain.nim --- a/semicongine/rendering/swapchain.nim Wed Sep 24 21:57:52 2025 +0700 +++ b/semicongine/rendering/swapchain.nim Wed Sep 24 22:14:44 2025 +0700 @@ -155,11 +155,11 @@ # create sync primitives for i in 0 ..< INFLIGHTFRAMES: swapchain.queueFinishedFence[i] = svkCreateFence(signaled = true) - swapchain.renderFinishedSemaphore[i] = svkCreateSemaphore() + swapchain.imageAvailableSemaphore[i] = svkCreateSemaphore() - swapchain.imageAvailableSemaphore.setLen(framebuffers.len) - for i in 0 ..< framebuffers.len: - swapchain.imageAvailableSemaphore[i] = svkCreateSemaphore() + swapchain.renderFinishedSemaphore.setLen(swapchain.framebuffers.len) + for i in 0 .. swapchain.renderFinishedSemaphore.high: + swapchain.renderFinishedSemaphore[i] = svkCreateSemaphore() # command buffers var commandPoolCreateInfo = VkCommandPoolCreateInfo( @@ -227,7 +227,7 @@ swapchain.vk, # high(uint64), 10_000_000'u64, # wait max 10ms - swapchain.imageAvailableSemaphore[swapchain.currentFramebufferIndex], + swapchain.imageAvailableSemaphore[swapchain.currentFiF], VkFence(0), addr(swapchain.currentFramebufferIndex), ) @@ -239,18 +239,17 @@ return some(swapchain.framebuffers[swapchain.currentFramebufferIndex]) proc swap(swapchain: Swapchain, commandBuffer: VkCommandBuffer): bool = - debugecho "currentFiF: ", swapchain.currentFiF var waitStage = VkPipelineStageFlags(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) submitInfo = VkSubmitInfo( sType: VK_STRUCTURE_TYPE_SUBMIT_INFO, waitSemaphoreCount: 1, - pWaitSemaphores: addr(swapchain.imageAvailableSemaphore[swapchain.currentFramebufferIndex]), + pWaitSemaphores: addr(swapchain.imageAvailableSemaphore[swapchain.currentFiF]), pWaitDstStageMask: addr(waitStage), commandBufferCount: 1, pCommandBuffers: addr(commandBuffer), signalSemaphoreCount: 1, - pSignalSemaphores: addr(swapchain.renderFinishedSemaphore[swapchain.currentFiF]), + pSignalSemaphores: addr(swapchain.renderFinishedSemaphore[swapchain.currentFramebufferIndex]), ) checkVkResult vkQueueSubmit( queue = engine().vulkan.graphicsQueue, @@ -262,7 +261,7 @@ var presentInfo = VkPresentInfoKHR( sType: VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, waitSemaphoreCount: 1, - pWaitSemaphores: addr(swapchain.renderFinishedSemaphore[swapchain.currentFiF]), + pWaitSemaphores: addr(swapchain.renderFinishedSemaphore[swapchain.currentFramebufferIndex]), swapchainCount: 1, pSwapchains: addr(swapchain.vk), pImageIndices: addr(swapchain.currentFramebufferIndex),