Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::DescriptorIndexAllocator Class Reference

Use this class to manage a finite amount of memory. The idea is to have an array which stores objects and a vector which has pointers to said objects in the array. The array is sparsely populated using optionals. More...

#include <DescriptorIndexAllocator.h>

Collaboration diagram for Engine::Core::DescriptorIndexAllocator:

Public Member Functions

 DescriptorIndexAllocator ()=delete
 DescriptorIndexAllocator (int descriptorCount)
uint32_t allocate ()
 Get an index where there is no data in the array.
void free (uint32_t index)
 Frees a cell in the array where the memory is not used anymore.
const std::vector< uint32_t > & getUsedIndices () const
 Gets the indices of all allocated fields in the array.
void reset (int newSize)
 Resets all values in the buffers and allocates with new size.
size_t getCapacity () const

Private Attributes

std::stack< uint32_t > freeIndices
std::vector< uint32_t > usedIndices
uint32_t capacity

Detailed Description

Use this class to manage a finite amount of memory. The idea is to have an array which stores objects and a vector which has pointers to said objects in the array. The array is sparsely populated using optionals.

Definition at line 12 of file DescriptorIndexAllocator.h.

Constructor & Destructor Documentation

◆ DescriptorIndexAllocator() [1/2]

Engine::Core::DescriptorIndexAllocator::DescriptorIndexAllocator ( )
delete

◆ DescriptorIndexAllocator() [2/2]

Engine::Core::DescriptorIndexAllocator::DescriptorIndexAllocator ( int descriptorCount)
explicit

Member Function Documentation

◆ allocate()

uint32_t Engine::Core::DescriptorIndexAllocator::allocate ( )
nodiscard

Get an index where there is no data in the array.

Returns
an index in the array which does not have data
Exceptions
AllocationExceptionwhen there are no free elements left

◆ free()

void Engine::Core::DescriptorIndexAllocator::free ( uint32_t index)

Frees a cell in the array where the memory is not used anymore.

Parameters
indexthe index in the array to release back into the pool of free memory

◆ getCapacity()

size_t Engine::Core::DescriptorIndexAllocator::getCapacity ( ) const

◆ getUsedIndices()

const std::vector< uint32_t > & Engine::Core::DescriptorIndexAllocator::getUsedIndices ( ) const
nodiscard

Gets the indices of all allocated fields in the array.

Returns
list of all indices of allocated cells in the array

◆ reset()

void Engine::Core::DescriptorIndexAllocator::reset ( int newSize)

Resets all values in the buffers and allocates with new size.

Parameters
newSizeSize of the new allocator

Member Data Documentation

◆ capacity

uint32_t Engine::Core::DescriptorIndexAllocator::capacity
private

Definition at line 52 of file DescriptorIndexAllocator.h.

◆ freeIndices

std::stack<uint32_t> Engine::Core::DescriptorIndexAllocator::freeIndices
private

Definition at line 50 of file DescriptorIndexAllocator.h.

◆ usedIndices

std::vector<uint32_t> Engine::Core::DescriptorIndexAllocator::usedIndices
private

Definition at line 51 of file DescriptorIndexAllocator.h.


The documentation for this class was generated from the following file: