12 if (!pool)
return NULL;
28 for (uint32_t i = 0; i < pool->
capacity; ++i) {
35 if (is_new) *is_new =
false;
42 int32_t lru_index = -1;
43 int32_t empty_index = -1;
44 uint64_t min_frame = UINT64_MAX;
46 for (uint32_t i = 0; i < pool->
capacity; ++i) {
49 if (empty_index == -1) {
50 empty_index = (int32_t)i;
56 lru_index = (int32_t)i;
62 int32_t target_index = (empty_index != -1) ? empty_index : lru_index;
65 if (target_index == -1) {
70 pool->
active[target_index] = 1;
73 if (is_new) *is_new =
true;
void VoxelPool_UpdateFrame(VoxelPool *pool, uint64_t frame)
Advances the pool's internal frame counter for LRU tracking.
VoxelPool * VoxelPool_Init(SblArena *arena, uint32_t capacity)
Initializes a VoxelPool on the provided arena.
int32_t VoxelPool_AcquireSlot(VoxelPool *pool, sbgl_ivec3 pos, bool *is_new)
Acquires a slot for a given chunk position. Returns the slot index (0 to capacity-1)....
SBL_ARENA_DEF void * sbl_arena_alloc_zero(SblArena *arena, uint64_t size)
VoxelPool manages a fixed number of slots for voxel chunks. It uses a flat array layout to maintain c...
uint64_t * last_used_frames
3D integer vector for chunk coordinates.