Skip to content

Resizable VmaVirtualBlocks #495

@theagentd

Description

@theagentd

Hello!

We have an issue where we use a VmaVirtualBlock to suballocate a buffer for storing 3D model vertex and index data. At times, we run out of memory in this buffer and need to resize it by creating a new one, copying the data to the new one and freeing the old buffer. This works fine.

Unfortunately, the VmaVirtualBlock we use for suballocation cannot be resized to the new size. This leads us to need to either:

  • create multiple allocators for each range of memory we add, which increases fragmentation and causes alignment issues for the different ranges.
  • create a new VmaVirtualBlock and manually reconstruct its state using carefully done allocations and frees to introduce the same gaps as before. This requires us to track all allocations, sort them and go through them, making resizes very complex.

EDIT: While writing this, I came up with a third, much easier, workaround: Allocate a VmaVirtualBlock for the largest size we will ever need (say 8GB), and fill it with dummy allocations of the resize granularity (64 MBs in our case) to "reserve" space. When resizing, just free these reservations to "increase" the size of the virtual block.

Regardless, it seems to me that adding the ability to resize a VmaVirtualBlock should be relatively straightforward endeavor. Either extend the final free range until the end of the block, or add a new free range if there is none. Even shrinking a block shouldn't be too complicated, if we add the requirement that the range being removed must be empty of allocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureAdding new featurefuture releaseTo be done some time in the future

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions