[perf] Per-allocation vkAllocateMemory, no suballocator #62

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

Subsystem: VulkanBuffer / memory allocation
Location: interfaces/Crafter.Graphics-VulkanBuffer.cppm:73-90
Impact: Medium (allocation-count exhaustion) · Effort: Large · Not per-frame (mesh-build/heap-init/topology-change)
Builds on: #101 / #102 (fence-keyed deferred-deletion queue — landed)

Problem

One VkDeviceMemory per buffer, no suballocator — counts against maxMemoryAllocationCount. The legitimate concern is allocation-count exhaustion for thousand-mesh scenes, not frame cost.

Proposed fix

Suballocator / memory pool.

Correctness caveat

A suballocator must honor frame-in-flight lifetimes (fence tracking) — a naive slab that recycles ranges is a GPU-side use-after-free. The fence-keyed retirement primitive now exists (deletion queue from #102): retiring a whole pool block can go straight through Device::EnqueueDeletion, and a sub-range recycler should reuse the same frameCounter + framesInFlight retire logic on its free-list entries rather than re-deriving fence tracking. Large effort regardless.

**Subsystem:** VulkanBuffer / memory allocation **Location:** `interfaces/Crafter.Graphics-VulkanBuffer.cppm:73-90` **Impact:** Medium (allocation-count exhaustion) · **Effort:** Large · Not per-frame (mesh-build/heap-init/topology-change) **Builds on:** #101 / #102 (fence-keyed deferred-deletion queue — landed) ### Problem One `VkDeviceMemory` per buffer, no suballocator — counts against `maxMemoryAllocationCount`. The legitimate concern is allocation-count exhaustion for thousand-mesh scenes, not frame cost. ### Proposed fix Suballocator / memory pool. ### Correctness caveat A suballocator **must** honor frame-in-flight lifetimes (fence tracking) — a naive slab that recycles ranges is a GPU-side use-after-free. **The fence-keyed retirement primitive now exists** (deletion queue from #102): retiring a whole pool block can go straight through `Device::EnqueueDeletion`, and a sub-range recycler should reuse the same `frameCounter + framesInFlight` retire logic on its free-list entries rather than re-deriving fence tracking. Large effort regardless.
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#62
No description provided.