[perf][LOW] Invariant Vulkan structs rebuilt every frame #43

Closed
opened 2026-06-16 16:51:30 +02:00 by jorijnvdgraaf · 0 comments

Subsystem: Window / swapchain / frame loop
Location: implementations/Crafter.Graphics-Window.cpp:688-694, 696-724, 789-817
Impact: LOW · Effort: Small

Problem

cmdBufInfo, the subresource range, both VkImageMemoryBarrier structs, and presentInfo are reconstructed on the stack every frame though only barrier.image/oldLayout and barrier2.image vary. The per-frame renderComplete != VK_NULL_HANDLE check (813-817) is dead — set once, never cleared.

Proposed fix

Hoist invariants to members initialized in the constructor (presentInfo.pImageIndices = &currentBuffer auto-tracks); per frame patch only barrier.image/oldLayout. Drop the dead null check.

Note

VkSubmitInfo is already a member, initialized once — only the begin-info, range, two barriers, and present-info apply. Single-digit-ns win; dwarfed by the wait-idle and per-pass barriers.

**Subsystem:** Window / swapchain / frame loop **Location:** `implementations/Crafter.Graphics-Window.cpp:688-694, 696-724, 789-817` **Impact:** LOW · **Effort:** Small ### Problem `cmdBufInfo`, the subresource `range`, both `VkImageMemoryBarrier` structs, and `presentInfo` are reconstructed on the stack every frame though only `barrier.image`/`oldLayout` and `barrier2.image` vary. The per-frame `renderComplete != VK_NULL_HANDLE` check (813-817) is dead — set once, never cleared. ### Proposed fix Hoist invariants to members initialized in the constructor (`presentInfo.pImageIndices = &currentBuffer` auto-tracks); per frame patch only `barrier.image`/`oldLayout`. Drop the dead null check. ### Note `VkSubmitInfo` is *already* a member, initialized once — only the begin-info, range, two barriers, and present-info apply. Single-digit-ns win; dwarfed by the wait-idle and per-pass barriers.
catbot 2026-06-16 17:27:49 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Catcrafts/Crafter.Graphics#43
No description provided.