Querying for memory budget and staying within the budget is a very needed feature of the Vulkan Memory Allocator library. I implemented prototype of it on a separate branch "MemoryBudget".
It also contains documentation of all new symbols and a general chapter "Staying within budget" that describes this topic. Documentation is pregenerated so it can be accessed by just downloading the repository as ZIP, unpacking, and opening file "docs\html\index.html" > chapter “Staying within budget”.
If you are interested, please take a look. Any feedback is welcomed - you can leave your comment below or send me an e-mail. Now is the best time to adjust this feature to users' needs before it gets into the official release of the library.
Long story short:
A function is added to query for current memory usage and available budget per Vulkan memory heap.
If you enable extension VK_EXT_memory_budget and tell VMA about it, the extension is used for that query. If not, current usage and budget is estimated based on total size of currently allocated blocks made and 80% of heap sizes, respectively.
If you are close to exceeding the budget or it is already exceeded, the library doesn’t allocate another default 256 MB memory block. It instead tries to allocate smaller block or even dedicated allocation just for your resource, to stay withing the budget.
It still tries to make the allocation and leaves to Vulkan the decision whether the allocation succeeds or fails, unless you use new VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT, which causes the allocation to just return failure if it would go over budget.