|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
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>
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 |
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 15 of file DescriptorIndexAllocator.h.
|
delete |
|
explicit |
Definition at line 9 of file DescriptorIndexAllocator.cpp.
References capacity, and freeIndices.
|
nodiscard |
Get an index where there is no data in the array.
| AllocationException | when there are no free elements left |
Definition at line 15 of file DescriptorIndexAllocator.cpp.
References freeIndices, and usedIndices.
| void EngineCore::DescriptorIndexAllocator::free | ( | uint32_t | index | ) |
Frees a cell in the array where the memory is not used anymore.
| index | the index in the array to release back into the pool of free memory |
Definition at line 28 of file DescriptorIndexAllocator.cpp.
References freeIndices, and usedIndices.
| size_t EngineCore::DescriptorIndexAllocator::getCapacity | ( | ) | const |
Definition at line 51 of file DescriptorIndexAllocator.cpp.
References capacity.
|
nodiscard |
Gets the indices of all allocated fields in the array.
Definition at line 34 of file DescriptorIndexAllocator.cpp.
References usedIndices.
| void EngineCore::DescriptorIndexAllocator::reset | ( | int | newSize | ) |
Resets all values in the buffers and allocates with new size.
| newSize | Size of the new allocator |
Definition at line 39 of file DescriptorIndexAllocator.cpp.
References freeIndices, and usedIndices.
|
private |
Definition at line 68 of file DescriptorIndexAllocator.h.
Referenced by DescriptorIndexAllocator(), and getCapacity().
|
private |
Definition at line 66 of file DescriptorIndexAllocator.h.
Referenced by allocate(), DescriptorIndexAllocator(), free(), and reset().
|
private |
Definition at line 67 of file DescriptorIndexAllocator.h.
Referenced by allocate(), free(), getUsedIndices(), and reset().