fix: use one render-finished semaphore per swapchain image - #183
Closed
TommyRadan wants to merge 1 commit into
Closed
fix: use one render-finished semaphore per swapchain image#183TommyRadan wants to merge 1 commit into
TommyRadan wants to merge 1 commit into
Conversation
The Vulkan backend signaled and present-waited on a single device-wide m_render_finished semaphore every frame. The in-flight fence only gates the submit, not the present, so with 3 swapchain images frame N+1's submit could re-signal the semaphore while frame N's present was still using it, tripping VUID-vkQueueSubmit-pSignalSemaphores-00067. Use one render-finished semaphore per swapchain image, indexed by the acquired image index, and tie its lifetime to the swapchain so it tracks image-count changes on resize. A semaphore bound to a specific image is not re-signaled until that image is re-acquired, which the acquire/fence flow already gates, so the reuse hazard is gone. Closes #151
CI build artifactsWindows Debug and Release builds are attached to the workflow run summary under Artifacts:
Run #249 — commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Vulkan validation error from #151:
VUID-vkQueueSubmit-pSignalSemaphores-00067— the swapchain render-finished semaphore was reused across frames.The backend signaled and present-waited on a single device-wide
m_render_finishedsemaphore. The in-flight fence only gates the submit, not the present, so with 3 swapchain images frame N+1's submit could re-signal the semaphore while frame N's present was still using it.Changes
vk_device.hpp:m_render_finishedis now astd::vector<VkSemaphore>(one per swapchain image) instead of a single handle.create_swapchain/destroy_swapchain: create and destroy the per-image semaphores alongside the swapchain, so the count tracks image-count changes on resize.create_sync_objects/destroy_sync_objects: now own onlym_image_availableandm_in_flight_fence.submit: signals and present-waits onm_render_finished[m_current_image_index].A semaphore tied to a specific image is not re-signaled until that image is re-acquired — already gated by the acquire/fence flow — so the reuse hazard is gone.
m_image_availableandm_in_flight_fenceare unchanged (single-frame-in-flight model).Testing
AlphaEnginetarget (Ninja, Debug) — links cleanly.clang-format-18clean on both changed files.Note: the validation message itself wasn't re-run — this was built in a headless container with no GPU/display, so the fix is verified by build + code reasoning rather than a live capture.
Closes #151
Generated by Claude Code