Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
DescriptorIndexAllocator.h
1#pragma once
2#include <cstdint>
3#include <stack>
4#include <vector>
5
6namespace Engine::Core
7{
13{
14public:
19
24 explicit DescriptorIndexAllocator(int descriptorCount);
25
32 [[nodiscard]] uint32_t allocate();
33
38 void reserve( uint32_t index );
39
45 void free(uint32_t index);
46
52 [[nodiscard]] const std::vector<uint32_t> &getUsedIndices() const;
53
59 void reset(int newSize);
60
64 size_t getCapacity() const;
65
66private:
67 std::stack<uint32_t> freeIndices;
68 std::vector<uint32_t> usedIndices;
69 uint32_t capacity;
70};
71}
uint32_t allocate()
Get an index where there is no data in the array.
DescriptorIndexAllocator(int descriptorCount)
Creates an allocator with descriptor indices in the range [0, descriptorCount).
size_t getCapacity() const
Gets the number of descriptor indices managed by the allocator.
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.
DescriptorIndexAllocator()=delete
Default construction is disabled because the allocator needs a fixed capacity.
void free(uint32_t index)
Frees a cell in the array where the memory is not used anymore.
void reserve(uint32_t index)
Marks a specific free index as allocated.