Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::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 EngineCore::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.

Date
2025-05-31
Author
Konstantin Passig

Definition at line 15 of file DescriptorIndexAllocator.h.

Constructor & Destructor Documentation

◆ DescriptorIndexAllocator() [1/2]

EngineCore::DescriptorIndexAllocator::DescriptorIndexAllocator ( )
delete

◆ DescriptorIndexAllocator() [2/2]

EngineCore::DescriptorIndexAllocator::DescriptorIndexAllocator ( int descriptorCount)
explicit

Definition at line 9 of file DescriptorIndexAllocator.cpp.

References capacity, and freeIndices.

Member Function Documentation

◆ allocate()

uint32_t EngineCore::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
Date
2025-05-31
Author
Konstantin Passig
Exceptions
AllocationExceptionwhen there are no free elements left

Definition at line 15 of file DescriptorIndexAllocator.cpp.

References freeIndices, and usedIndices.

◆ free()

void EngineCore::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
Date
2025-05-31
Author
Konstantin Passig

Definition at line 28 of file DescriptorIndexAllocator.cpp.

References freeIndices, and usedIndices.

◆ getCapacity()

size_t EngineCore::DescriptorIndexAllocator::getCapacity ( ) const

Definition at line 51 of file DescriptorIndexAllocator.cpp.

References capacity.

◆ getUsedIndices()

const std::vector< uint32_t > & EngineCore::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
Date
2025-05-31
Author
Konstantin Passig

Definition at line 34 of file DescriptorIndexAllocator.cpp.

References usedIndices.

◆ reset()

void EngineCore::DescriptorIndexAllocator::reset ( int newSize)

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

Parameters
newSizeSize of the new allocator
Date
2025-10-07
Author
Konstantin Passig

Definition at line 39 of file DescriptorIndexAllocator.cpp.

References freeIndices, and usedIndices.

Member Data Documentation

◆ capacity

uint32_t EngineCore::DescriptorIndexAllocator::capacity
private

Definition at line 68 of file DescriptorIndexAllocator.h.

Referenced by DescriptorIndexAllocator(), and getCapacity().

◆ freeIndices

std::stack<uint32_t> EngineCore::DescriptorIndexAllocator::freeIndices
private

Definition at line 66 of file DescriptorIndexAllocator.h.

Referenced by allocate(), DescriptorIndexAllocator(), free(), and reset().

◆ usedIndices

std::vector<uint32_t> EngineCore::DescriptorIndexAllocator::usedIndices
private

Definition at line 67 of file DescriptorIndexAllocator.h.

Referenced by allocate(), free(), getUsedIndices(), and reset().


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