razerx100 / Terra

Renderer module based on Vulkan.
MIT License
0 stars 0 forks source link

Replace the temp Upload buffer of StagingBufferManager with a single buffer #28

Closed razerx100 closed 1 month ago

razerx100 commented 4 months ago

As now I am creating a new Buffer object for each upload, and at one point we can potentially have millions of buffers. Which would be kinda stupid. So, it would be better to have an expandable Upload buffer.

But it might be the case that at one point we are allocating a lot of things and so the Upload buffer might get huge. It might be a good idea to have a fixed size and we can make it as bigger as possible but once all of the copying are done, shrink it down to the fixed size, just so we don't waste space.

razerx100 commented 4 months ago

After thinking a little bit, replacing the multiple buffers with a single one wouldn't be that helpful, as we will still need to recreate and make the temp buffer bigger. And even when we are clearing it all, to get the minimum fixed buffer, we would need another recreation.

Not clearing the temp buffer would be better but would be a waste of space.

We can probably do somewhat like an Arena allocation but we are kinda already doing that. We could perhaps put more buffers in a single temp buffer but that would require more calculations but wouldn't really be that better than what we are currently doing.

I will keep this open for now in case I find a better solution at some point. I will try to do some benchmarking and see if I can find a better solution.

razerx100 commented 1 month ago

Maybe it is not worth it? Closing for now.