[perf] Frame-loop barriers use ALL_COMMANDS scope (inter-pass + acquire/present) (Window.cpp) #115
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#115
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?
Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).
This issue covers all
ALL_COMMANDS-scoped barriers in the frame loop — both the inter-pass barriers and the acquire/present barriers. They share one fix (derive the real per-pass stage union) and one correctness constraint (RT passes), so they are a single co-dependent deliverable. (Merged from the former #117.)Locations:
implementations/Crafter.Graphics-Window.cpp:881-888(inter-pass) and:818-893(acquire/present)Severity: medium · Effort: moderate · Category: sync
Problem
:881-888): between two consecutive passes a globalVkMemoryBarriersets bothsrcStageMaskanddstStageMasktoALL_COMMANDS, flushing/invalidating all caches and fully serializing against every pipeline stage — when all the next pass needs is the swapchain image written by the previous one to be visible.:818-893): the acquiredstStageMaskand presentsrcStageMaskare alsoALL_COMMANDS, though the swapchain image is only written by compute/RT.Both defeat the GPU's ability to overlap the tail of one pass with the head of the next, and force full cache round-trips every frame.
Fix
Replace the inter-pass global barrier with an image memory barrier scoped to the swapchain image (the codebase already does this intra-pass at
UI.cpp:264), and narrow the acquire/present stage masks to the actual writer stages.Constraint (why moderate, not trivial)
Passes are polymorphic: a compute pass writes via
COMPUTE_SHADER, an RT pass viaRAY_TRACING_SHADER. A hardcodedCOMPUTE→COMPUTEmask would under-synchronize an RT pass and produce a correctness bug. Derive the stage mask per-pass from what each pass actually does, or use the conservative-but-tight unionCOMPUTE_SHADER | RAY_TRACING_SHADER | TRANSFERfor the frame-edge barriers. These are frame-edge/per-pass barriers, so the practical bubble is modest but the per-frame cache flush is real.[perf] Inter-pass barrier is ALL_COMMANDS global cache flush per frame (Window.cpp)to [perf] Frame-loop barriers use ALL_COMMANDS scope (inter-pass + acquire/present) (Window.cpp)