Say I run into a situation where I would like to change a vulkan buffer's (VkBuffer) size. For example, if I wanted to add more vertices to an existing vertex buffer. How would I grow/shrink a VkBuffer? Would I be forced to just create a new buffer and abandon the old one, or is there functionality similar to C's realloc
? Does it exist in the form of a vulkan extension?
In addition, I'm using the Vulkan Memory Allocator (VMA). I would like both solutions using VMA and raw vulkan if there is such realloc
functionality.
There is no realloc
in VMA nor Vulkan extensions.
Historically, there was vmaResizeAllocation()
, but it was deprecated and is now defunct.
For grow you need to anticipate and preallocate some extra size, or get a new allocation. For shrink you can use the memory you already have, or get a new one.
If you get a new allocation you must do an explicit copy, which might also have consequences for synchronization. So it is kinda out of scope of VMA, and also perhaps not that great for many allocator algorithms.