Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMA (pool) slower than a custom cache of buffers #453

Open
jzubizarreta opened this issue Nov 12, 2024 · 1 comment
Open

VMA (pool) slower than a custom cache of buffers #453

jzubizarreta opened this issue Nov 12, 2024 · 1 comment
Labels
question Further information is requested

Comments

@jzubizarreta
Copy link

I noticed than allocating and deallocating the same buffer in each of my compute iterations is very slow.
I was expecting VMA to handle this efficiently because it has a pool internally. My intuition is that when a buffer is deallocated, it goes back to the pool, and if the same type of buffer is allocated again, the one in the pool will be reused. However, in my system that behaviour is very slow and I'm sure that the same type/size of buffers are allocated every iteration. I tried with a custom map of buffers and that's way faster. Any idea way? Thanks in advance

@adam-sawicki-a adam-sawicki-a added the question Further information is requested label Nov 13, 2024
@adam-sawicki-a
Copy link
Contributor

VMA doesn't keep a pool of VkBuffer or VkImage objects. If you call vmaDestroyBuffer, the buffer gets destroyed. Creating and destroying buffers can have some performance overhead.

What VMA can help with is allocating large VkDeviceMemory blocks and assigning parts of them to the buffers and images you create. Thus, if you repeatedly create and destroy buffers, chances are that an existing Vulkan memory block is reused and no allocations or deallocations are made. Allocating Vulkan memory could have even bigger performance overhead. Still, this is based on internal heuristics and there are no guarantess.

It is not recommended to create and destroy buffers or images on every rendering frame or compute iteration. I recommend you implementing your own pool of buffers to reuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants