142 this->
nodes.Resize(maxNumAllocs);
173 for (
uint i = 0; i < this->
nodes.Size(); i++)
206 uint alignedSize =
size + alignment - 1;
213 uint bin = 0xFFFFFFFF;
221 if (bin == 0xFFFFFFFF)
227 if (bucket == 0xFFFFFFFF)
248 node.
size = alignedSize;
273 uint remainder = totalSize - node.
size;
343 this->
nodes[leftNode].blockNext = mergedNode;
344 this->
nodes[mergedNode].blockPrev = leftNode;
349 this->
nodes[rightNode].blockPrev = mergedNode;
350 this->
nodes[mergedNode].blockNext = rightNode;
380 newNode.
binNext = headNodeIndex;
391 headNode.
binPrev = newNodeIndex;
454 _BitScanReverse(&count,
size);
456 int count = 31 - __builtin_clz(
size);
483 if ((~mask &
size) != 0)
Implements helper functions for checking bits.
Allocates memory ranges using the TLSF method, with extended handling of padding to better suit GPUs.
~RangeAllocator()
Destructor.
Definition rangeallocator.h:152
RangeAllocator()
Default constructor.
Definition rangeallocator.h:129
void Clear()
Clears the allocator.
Definition rangeallocator.h:160
uint size
Definition rangeallocator.h:110
static uint BinFromSize(uint size, uint bucket)
Get bin from index.
Definition rangeallocator.h:465
Util::Array< RangeAllocatorNode > nodes
Definition rangeallocator.h:121
void RemoveNode(uint nodeIndex)
Remove node from bin.
Definition rangeallocator.h:402
uint InsertNode(uint size, uint offset)
Insert node at bin location, return node index.
Definition rangeallocator.h:358
static constexpr uint NUM_BUCKETS
Definition rangeallocator.h:114
static uint BucketFromSize(uint size)
Get bucket from index.
Definition rangeallocator.h:450
static constexpr uint NUM_BINS_PER_BUCKET
Definition rangeallocator.h:115
uint bucketUsageMask
Definition rangeallocator.h:117
bool Empty()
Checks if the allocator is empty.
Definition rangeallocator.h:189
uint freeNodeIterator
Definition rangeallocator.h:112
static BinIndex IndexFromSize(uint size, bool round=false)
Get bin index from size.
Definition rangeallocator.h:475
RangeAllocation Alloc(uint size, uint alignment=1)
Allocate range.
Definition rangeallocator.h:203
uint binMasks[NUM_BUCKETS]
Definition rangeallocator.h:118
uint freeStorage
Definition rangeallocator.h:111
Util::Array< uint > freeNodes
Definition rangeallocator.h:122
void Dealloc(const RangeAllocation &allocation)
Deallocate range.
Definition rangeallocator.h:299
uint binHeads[NUM_BUCKETS *NUM_BINS_PER_BUCKET]
Definition rangeallocator.h:119
Nebula's dynamic array class.
Definition array.h:60
void Resize(SizeT num)
Set size. Grows array if num is greater than capacity. Calls destroy on all objects at index > num!
Definition array.h:1606
const SizeT Size() const
get number of elements in array
Definition array.h:880
#define n_assert(exp)
Definition debug.h:50
__forceinline unsigned int align(unsigned int alignant, unsigned int alignment)
Definition scalar.h:722
Definition arenaallocator.h:31
uint Lsb(uint value, byte bit)
Definition bit.h:229
uint FirstOne(uint value)
Definition bit.h:169
Describes a range allocated by the Memory::RangeAllocator.
uint offset
Definition rangeallocator.h:26
static constexpr uint OOM
Definition rangeallocator.h:30
uint size
Definition rangeallocator.h:27
uint node
Definition rangeallocator.h:28
Definition rangeallocator.h:73
uint offset
Definition rangeallocator.h:85
bool resident
Definition rangeallocator.h:83
static constexpr uint END
Definition rangeallocator.h:87
uint blockNext
Definition rangeallocator.h:89
uint size
Definition rangeallocator.h:84
RangeAllocatorNode()
Definition rangeallocator.h:74
uint blockPrev
Definition rangeallocator.h:89
uint binPrev
Definition rangeallocator.h:88
uint binNext
Definition rangeallocator.h:88
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
uint16_t uint16
Definition types.h:40
Definition rangeallocator.h:93
uint16 index
Definition rangeallocator.h:100
uint16 bucket
Definition rangeallocator.h:98
BinIndex()
Definition rangeallocator.h:94
uint16 bin
Definition rangeallocator.h:97