[VMA] Phase 2 — switch suballocator to VMA Virtual Blocks, add budget-aware reclaim & safer commit #345

Closed
wildcard wants to merge 2 commits from VMA_Changes_v1 into master
Member

[V2]
Replace the custom suballocator (std::vector + gap scan) with VMA Virtual Blocks
Suballocator architecture
Old code used, commits vector of ranges + FindFreeRegion() linear scan whereas the new uses per-block VmaVirtualBlock with vmaVirtualAllocate/Free.
Similarly,
the MemoryAllocation::Commit(size, alignment) now uses VB.
MemoryAllocation::Free(begin) → vmaVirtualFree() by stored handle.
TLDR,
Introduce VmaVirtualBlock in MemoryAllocation; RAII destruction in dtor and all the corresponding handling changes to VB.
And all the previous goodies from V1.
[V1]
This patch makes VMA suballocation smarter under pressure and fixes a masking bug when RenderDoc is attached.
Adds a budget-aware check (via vmaGetHeapBudgets) and attempts to reclaim empty internal blocks before allocating new device memory blocks.
Implements a bounded OOM recovery ladder (retry, trim empty blocks, relax DEVICE_LOCAL, fall back to a smaller chunk, then fail).
This is phase one of the VMA changes and after testing, phase 2 shall roll out.

[V2] Replace the custom suballocator (std::vector<Range> + gap scan) with VMA Virtual Blocks Suballocator architecture Old code used, commits vector of ranges + FindFreeRegion() linear scan whereas the new uses per-block VmaVirtualBlock with vmaVirtualAllocate/Free. Similarly, the MemoryAllocation::Commit(size, alignment) now uses VB. MemoryAllocation::Free(begin) → vmaVirtualFree() by stored handle. TLDR, Introduce VmaVirtualBlock in MemoryAllocation; RAII destruction in dtor and all the corresponding handling changes to VB. And all the previous goodies from V1. [V1] This patch makes VMA suballocation smarter under pressure and fixes a masking bug when RenderDoc is attached. Adds a budget-aware check (via vmaGetHeapBudgets) and attempts to reclaim empty internal blocks before allocating new device memory blocks. Implements a bounded OOM recovery ladder (retry, trim empty blocks, relax DEVICE_LOCAL, fall back to a smaller chunk, then fail). This is phase one of the VMA changes and after testing, phase 2 shall roll out.
Lizzie reviewed 2025-08-29 00:46:51 +02:00
@ -303,0 +369,4 @@
}
}
throw vk::Exception(VK_ERROR_OUT_OF_DEVICE_MEMORY);
Member

Sadpath codegen for stack unwinding is not optimal for exceptions
Maybe exploring not having to use them?

Sadpath codegen for stack unwinding is not optimal for exceptions Maybe exploring not having to use them?
Author
Member

we can leave it as it is since if we are oom, we have bigger issues than making code optimal for exception.

we can leave it as it is since if we are oom, we have bigger issues than making code optimal for exception.
Lizzie reviewed 2025-08-29 00:59:37 +02:00
@ -286,0 +309,4 @@
}
void MemoryAllocator::FreeEmptyAllocations() {
std::vector<MemoryAllocation*> to_release;
Member

boost::container::small_vector

boost::container::small_vector
Author
Member

solved it by not using it

solved it by not using it
Author
Member

oh wait i am blind

oh wait i am blind
wildcard changed title from [VMA] phase 1: Budget aware sub allocation, "Actual" Robust OOM handling. to [VMA] Phase 2 — switch suballocator to VMA Virtual Blocks, add budget-aware reclaim & safer commit 2025-08-29 19:19:07 +02:00
Shinmegumi force-pushed VMA_Changes_v1 from 0942ea1cc9 to 69de851e84 2025-08-29 22:53:17 +02:00 Compare
wildcard closed this pull request 2025-09-01 05:06:30 +02:00
Author
Member

Request closed since it has been superseded by a better and more complete implementation. See Pr 362

Request closed since it has been superseded by a better and more complete implementation. See Pr 362
wildcard deleted branch VMA_Changes_v1 2025-09-01 05:07:29 +02:00
All checks were successful
eden-license / license-header (pull_request) Successful in 27s
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.