perf(ui): flush only the written descriptor range, not the whole heap (#61) #99
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!99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-61"
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?
Problem
WriteBufferDescriptor/WriteSampledImageDescriptor/RegisterSampler(and the swapchain/init paths) each called the whole-bufferFlushDevice()on the multi-KB per-frame descriptor heap after writing a single few-byte descriptor — flushing thousands of bytes of cache to push a handful.Fix
VulkanBuffer::FlushDevice(offset, bytes)— flushes only the touched byte range. It rounds the range outward toVkPhysicalDeviceLimits::nonCoherentAtomSize(cached onDevice), whichvkFlushMappedMemoryRangesrequires for a sub-buffer range; the oldVK_WHOLE_SIZEpath sidestepped that. The end is clamped to the mapping size so the call stays valid even when the allocation size is not atom-aligned (the spec'soffset+size == mapping sizeexception).WriteSwapchainDescriptors/WriteSampledImageDescriptor/WriteBufferDescriptor/RegisterSamplernow flush just their written descriptor range. The redundant whole-heap flushes inUIRenderer::Initializeand the resize callback are removed (each writer self-flushes).Correctness caveat (from the issue)
The ranged flush respects
nonCoherentAtomSizealignment, and the coherent skip is real coherence detection inherited from #60 — not a blanket skip.Testing
VulkanBufferRangedFlushtest drivesAlignMappedFlushRange(pure rounding math: sub-atom, straddling, already-aligned, atom==1, tail-clamp) and confirms the rangedFlushDevicekeeps the coherent gate — no GPU device needed.HelloUIon a real NVIDIA RTX 4090 with validation layers enabled: font-atlas glyphs, sampler, and storage-image descriptors all flush correctly, no flush/memory-range VUIDs.Screenshots
Resolves #61