Merge pull request 'perf(window): cache per-frame heap-bind structs across frames' (#77) from claude/issue-42 into master

This commit is contained in:
catbot 2026-06-16 17:27:55 +02:00
commit cea57f9af8
2 changed files with 41 additions and 21 deletions

View file

@ -281,6 +281,18 @@ export namespace Crafter {
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
std::vector<RenderPass*> passes;
DescriptorHeapVulkan* descriptorHeap = nullptr;
// Cached per-frame heap-bind structs. The heap address/size per slot
// are stable once a heap is assigned; only currentBuffer varies frame
// to frame, so the structs (and the reservedRangeOffset arithmetic)
// are computed once per heap rather than every frame in Render().
// Keyed on the heap pointer: whenever descriptorHeap differs from
// cachedDescriptorHeap the cache is rebuilt. This invalidates on any
// heap (re)assignment — heaps never resize today, so a stable pointer
// means stable ranges. Not tied to onResize (the heap is independent
// of swapchain size).
VkBindHeapInfoEXT resourceHeapInfos[numFrames];
VkBindHeapInfoEXT samplerHeapInfos[numFrames];
DescriptorHeapVulkan* cachedDescriptorHeap = nullptr;
std::optional<std::array<float, 4>> clearColor;
#else
// DOM mode: the page IS the window. WebGPU device and canvas are