perf(sync): scope frame-loop barriers to swapchain image + real per-pass stages (#115) #137
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!137
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-115"
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?
Summary
The frame loop's inter-pass barrier (
Window.cpp:881-888) and acquire/present barriers (:818,:893) set both stage masks toALL_COMMANDS, and the inter-pass dependency used a queue-wideVkMemoryBarrier. That fully serialised against every pipeline stage and forced a full cache flush/invalidate every frame, when all the next pass needs is the swapchain image the previous one wrote.This is the single co-dependent deliverable for both barrier families (merged from former #117): they share one fix (derive the real per-pass stage union) and one correctness constraint (RT passes).
Changes
Window.cpp): replaced the globalVkMemoryBarrierwith an image memory barrier scoped to the swapchain image's single colour subresource (BuildSwapchainInterPassBarrier) — only that image's caches round-trip, exactly as the intra-pass UI barrier atUI.cpp:264already does. The stage masks come from each pass's own stage.RenderPass::SwapchainStage()virtual, overridden byUIRenderer->COMPUTE_SHADERandRTPass->RAY_TRACING_SHADER. The acquiredst/ presentsrcmasks useSwapchainStageUnion(passes)— the real union of the frame's passes (an all-compute frame narrows toCOMPUTE_SHADERonly; any RT pass folds inRAY_TRACING_SHADER).COMPUTE->COMPUTEmask would under-synchronise an RT pass and corrupt the image. The base default and empty-passes fallback are the conservativeCOMPUTE_SHADER | RAY_TRACING_SHADER | TRANSFERunion, so a polymorphic or un-overridden pass can only be over-, never under-, synchronised.Tests
SwapchainBarrierScope(new, pure CPU — no GPU): pins that the compute and RT stages are distinct (the under-sync trap), that each pass type reports its real stage through the base pointer, thatSwapchainStageUnionnarrows an all-compute frame toCOMPUTE_SHADERonly and unions a mixed frame, and that the inter-pass barrier is scoped to the single swapchain subresource.FrameLoopSync(existing, real GPU + compositor): drives the real frame loop with the validation layer enabled and asserts zero validation errors — the regression guard for the narrowed acquire/present masks.Full suite: 21 passed (native). DOM/wasm target also builds clean.
Resolves #115
🤖 Generated with Claude Code