Closed IAmNotHanni closed 5 months ago
Hello
Thanks for your question. This is a good topic to discuss. I even considered an API like this, although it was for resources that alias in the same place in memory, which you didn't mention.
Short answer is: No such feature exists or is planned for VMA, but you can use existing pieces of the library interface to achieve your goals.
vmaCreateBuffer
is just a shortcut for doing vkGetBufferMemoryRequirements
+ vkCreateBuffer
+ vmaAllocateMemory
+ vmaBindBufferMemory
, so you are free to achieve (roughly) the same result doing these steps manually, if you want to e.g. query for the size + alignment of all buffers before allocating them.vmaAllocateMemory
and then bind buffers and images to it (possibly multiple of those, at different offsets) using vmaBindBufferMemory
/ vmaBindBufferMemory2
.vmaCreateAliasingBuffer2
.With aliasing resources, you need to determine what can alias with what and how place them in memory (at which offset within the allocation) by yourself.
Without aliasing, I don't think there would be any performance or memory benefit in providing a function like you proposed to allocate a batch of multiple buffers over separate calls to vmaCreateBuffer
, unless you mean the overhead of calling into the VMA library itself. For this, there is function vmaAllocateMemoryPages
available that creates multiple allocation objects (all with the same offset, size, and memory type) at once, which is intended mostly to help with sparse binding/residency.
Hello Thank you for this great answer! best regards Johannes
Hello
I am currently working on a rendergraph (framegraph). As we know, one of the advantages of this is that all the resources which are required are (ideally) known upfront, so it allows to be proactive in resource management, especially memory allocation. Until now, during compilation of my rendergraph, I create all the buffers which are required for rendering one by one in a simple loop.
This means VMA only knows about the already existing allocations and about the allocation that it's making next, but it does not know about all allocations which are upcoming in total. Depending on game engine design, it could though, right? I am wondering: Could there be some benefit for memory allocation if VMA would know about the "whole picture" of memory which is required? This way, maybe VMA could better reason about which resource to put in which place of memory.
For example I could imagine something like
vmaCreateBufferBatch
:Once my rendergraph would know which resources to allocate, I could do all allocations in one batch call and maybe VMA could maybe benefit from it in terms of deciding how to allocate memory.
What do you think?
best regards Johannes