Offset Allocator¶
| Spice | |
|---|---|
Allocation struct¶
Fields¶
| Name | Type | Description |
|---|---|---|
offset |
unsigned int |
Region struct¶
One size class of the allocator's free storage, used by getStorageReportFull()
Fields¶
| Name | Type | Description |
|---|---|---|
size |
unsigned int |
|
count |
unsigned int |
StorageReport struct¶
Summary of the allocator's free storage at a glance
Fields¶
| Name | Type | Description |
|---|---|---|
totalFreeSpace |
unsigned int |
|
largestFreeRegion |
unsigned int |
StorageReportFull struct¶
Detailed report of the allocator's free storage, broken down per leaf bin
Fields¶
| Name | Type | Description |
|---|---|---|
freeRegions |
Region[NUM_LEAF_BINS] |
Constructors¶
ctor¶
| Spice | |
|---|---|
Default-construct an empty full storage report; every entry is filled in by getStorageReportFull()
OffsetAllocator struct¶
An offset allocator that hands out regions from a fixed-size storage area using binned free lists. It manages offsets into an external storage block rather than memory itself, which makes it useful for sub-allocating GPU buffers or other contiguous resources.
The allocator owns its bookkeeping storage (the node pool and free list), so it must not be shallow-copied; copying (via the copy ctor or operator=) allocates and deep-copies fresh bookkeeping storage.
Constructors¶
ctor¶
| Spice | |
|---|---|
Construct an allocator managing a storage area of the given size
Parameters
| Name | Type | Description |
|---|---|---|
size |
unsigned int |
Total size of the managed storage area |
maxAllocas |
unsigned int |
Maximum number of concurrent allocations to support (default: 128 * 1024) |
ctor¶
| Spice | |
|---|---|
Construct an allocator as a deep copy of another allocator, so the two do not share bookkeeping storage
Parameters
| Name | Type | Description |
|---|---|---|
original |
const OffsetAllocator& |
OffsetAllocator to copy |
dtor¶
| Spice | |
|---|---|
Destruct the allocator, releasing its internal bookkeeping storage
Methods¶
allocate¶
| Spice | |
|---|---|
Allocate a region of the given size from the storage area
Parameters
| Name | Type | Description |
|---|---|---|
size |
unsigned int |
Size of the region to allocate |
Returns: Allocation — Allocation describing the reserved region
free¶
| Spice | |
|---|---|
Return a previously allocated region to the allocator
Parameters
| Name | Type | Description |
|---|---|---|
allocation |
Allocation |
Allocation to free |
getStorageReport¶
| Spice | |
|---|---|
Produce a summary report of the allocator's free storage
Returns: StorageReport — Storage report with total free space and largest free region
getStorageReportFull¶
| Spice | |
|---|---|
Produce a detailed report of the allocator's free storage, broken down per leaf bin
Returns: StorageReportFull — Full storage report
Operators¶
operator=¶
| Spice | |
|---|---|
Copy-assign the bookkeeping storage of another allocator into this one
Parameters
| Name | Type | Description |
|---|---|---|
newValue |
const OffsetAllocator& |
OffsetAllocator to copy from |