perf(window): hoist invariant per-frame Vulkan info structs to members (#43)
Window::Render() rebuilt cmdBufInfo, the subresource range, both VkImageMemoryBarrier structs, and presentInfo on the stack every frame even though only the barriers' image (and the acquire barrier's oldLayout) ever change. Hoist them to members initialised once in the constructor; Render() now patches only the two varying fields. presentInfo.pImageIndices/pSwapchains point at the currentBuffer and swapChain members, so they track value changes (including swapchain recreation) automatically. The render-complete wait semaphore is fixed for the window's lifetime, so the per-frame `renderComplete != NULL` check — set once, never cleared — was dead and is removed; the semaphore is wired into presentInfo in the constructor instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
050a44d118
commit
38616d81ef
2 changed files with 68 additions and 47 deletions
|
|
@ -259,6 +259,16 @@ export namespace Crafter {
|
|||
std::thread thread;
|
||||
VkCommandBuffer drawCmdBuffers[numFrames];
|
||||
VkSubmitInfo submitInfo;
|
||||
// Per-frame Vulkan info structs whose contents are almost entirely
|
||||
// invariant. Initialised once in the constructor; Render() patches only
|
||||
// the few fields that change each frame (the two barriers' image and
|
||||
// the acquire barrier's oldLayout). presentInfo.pImageIndices and
|
||||
// pSwapchains point at the currentBuffer/swapChain members, so they
|
||||
// track value changes (including swapchain recreation) automatically.
|
||||
VkCommandBufferBeginInfo cmdBufInfo;
|
||||
VkImageMemoryBarrier acquireBarrier;
|
||||
VkImageMemoryBarrier presentBarrier;
|
||||
VkPresentInfoKHR presentInfo;
|
||||
Semaphores semaphores;
|
||||
std::uint32_t currentBuffer = 0;
|
||||
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue