Memory region compaction is naive and often leads to excessive re-allocations
jellysquid3 opened this issue ยท 1 comments
GlBufferArena is rather naive and has a number of pitfalls that leads to poor frame time stability:
- Consecutive free regions in the memory buffer are never merged, resulting in a consecutive span being unusable for larger allocations. This causes excessive re-allocation of the buffer when there was available free space, but should be fairly easy to fix.
- In-place compaction of active regions is not supported without allocating a new buffer and copying everything over.
- The initial size for an arena is often too big and results in GPU memory being wasted when large areas of a chunk region are mostly air. Knowing the size of a chunk mesh before it's built is an impossible problem to solve, but the air chunks in a region could be quickly counted to better estimate an appropriate size. This depends on us moving the allocator/memory management for chunks outside of the chunk renderer.