vpr::Allocator class

The primary interface and class of this subsystem.

This object is responsible for creating resources when requested, managing memory, checking integrity of memory, and cleaning up after itself and when deallocation has been requested.

Constructors, destructors, conversion operators

Allocator(const VkDevice& parent_device, const VkPhysicalDevice& physical_device, allocation_extensions dedicated_alloc_enabled)
Allocator is attached to a single logical device and physical device.

Public functions

void Recreate()
Destroys and re-creates the allocator subsystem.
auto AllocateMemory(const VkMemoryRequirements& memory_reqs, const AllocationRequirements& alloc_details, const AllocationType& suballoc_type, Allocation& dest_allocation) -> VkResult
Called by clients to allocate memory into the passed Allocation reference.
void FreeMemory(const Allocation* memory_to_free)
Releases the memory used by the given Allocation.
auto AllocateForImage(VkImage& image_handle, const AllocationRequirements& details, const AllocationType& alloc_type, Allocation& dest_allocation) -> VkResult
Allocates memory for an image, using given handle to get requirements.
auto AllocateForBuffer(VkBuffer& buffer_handle, const AllocationRequirements& details, const AllocationType& alloc_type, Allocation& dest_allocation) -> VkResult
Much like AllocateForImage: uses given handle to get requirements, writes details of allocation ot given range, making memory valid for binding.

Function documentation

vpr::Allocator::Allocator(const VkDevice& parent_device, const VkPhysicalDevice& physical_device, allocation_extensions dedicated_alloc_enabled)

Allocator is attached to a single logical device and physical device.

Extensions for improved dedicated allocations are set based on parameter.

void vpr::Allocator::Recreate()

Destroys and re-creates the allocator subsystem.

Pre-existing allocations are destroyed and not rebuilt - the allocator is effectively "zeroed out".

VkResult vpr::Allocator::AllocateMemory(const VkMemoryRequirements& memory_reqs, const AllocationRequirements& alloc_details, const AllocationType& suballoc_type, Allocation& dest_allocation)

Called by clients to allocate memory into the passed Allocation reference.

Usually wiser to just use AllocateForBuffer or AllocateForImage.

VkResult vpr::Allocator::AllocateForImage(VkImage& image_handle, const AllocationRequirements& details, const AllocationType& alloc_type, Allocation& dest_allocation)

Allocates memory for an image, using given handle to get requirements.

Allocation information is written to dest_memory_range, so it can then be used to bind the resources together.