[perf][MEDIUM] Single shared semaphore pair prevents multiple frames in flight #41
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Subsystem: Window / swapchain / frame loop
Location:
implementations/Crafter.Graphics-Window.cpp:417-431, 675-682, 805-817Impact: MEDIUM (enabler) · Effort: Medium
Problem
Exactly one
presentCompleteand onerenderCompletesemaphore exist for the Window's lifetime, baked into the sharedsubmitInfo. With one pair you cannot have frame N's render-complete and frame N+1's acquire pending simultaneously. There are also zero fences in the class.Proposed fix
std::array<Semaphores, numFrames>indexed by a free-running CPU frame counter % numFrames — not bycurrentBuffer(the image index isn't known until after acquire). Acquire signalsframeSemaphores[frame].presentComplete; submit waits on it and signalsframeSemaphores[frame].renderComplete; present waits onrenderComplete.Correctness caveat
Today this is not an active race — the wait-idle masks it. It only becomes a fix once the wait-idle is removed. Per-frame semaphores alone also cause command-buffer use-after-free; the per-frame fences are mandatory. Bundle with the vkQueueWaitIdle issue.
Merged into #40 — per-frame fences and per-frame semaphores are a single, mutually-dependent deliverable (neither is correct on its own), so tracking them as one issue. Closing in favor of #40.