Mercurial > games > semicongine
changeset 1495:a9c0f899a734
fix: issue with presentation-wait semaphores, this time FR
author | sam <sam@basx.dev> |
---|---|
date | Wed, 24 Sep 2025 22:14:44 +0700 |
parents | 02e869aded5d |
children | 0615cd5bfd97 |
files | semicongine/core/types.nim semicongine/rendering/swapchain.nim |
diffstat | 2 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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),