perf(buffer): capacity-reuse in VulkanBuffer::Resize (#63) #96
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!96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-63"
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
VulkanBuffer::Resizealways destroyed + reallocated, even when the existing buffer already had room. Per-frame refit paths deliberately skip Resize (UPDATE mode), so this was never a steady-state cost — but capacity-reuse is the safer direction.Fix
Reuse the existing allocation in place when all of the following hold:
capacity,vkCreateBuffer),(memoryPropertyFlagsChosen & required) == required).preferredPropertyFlagsis a best-effort perf hint and does not affect correctness, so it is intentionally not part of the guard. On reuse the buffer handle, device address, and mapped pointer are all preserved; onlysizeshrinks to the new logical extent. Any mismatch falls back to the original destroy + recreate path.VulkanBufferBasenow trackscapacityandusageFlagsCreated, set inCreateand carried through the move constructor.Tests
Adds
VulkanBufferResizeReuse, a device-free regression test that stamps a fake handle + capacity/flags and drives the reuse guard directly, asserting the in-place path issues no Vulkan call (a real reallocate would fault with no device). Full suite: 14 passed (crafter-build test --jobs=1).Resolves #63
🤖 Generated with Claude Code