SBgl 0.1.0
A graphics framework in C99
Loading...
Searching...
No Matches
sbgl_pool.h
Go to the documentation of this file.
1#ifndef VOXEL_POOL_H
2#define VOXEL_POOL_H
3
4#include "sbgl_math.h"
5#include "core/sbl_arena.h"
6#include <stdint.h>
7#include <stdbool.h>
8
12typedef struct {
13 int32_t x, y, z;
15
20typedef struct {
22 uint64_t* last_used_frames;
23 uint8_t* active;
24 uint32_t capacity;
25 uint64_t current_frame;
26} VoxelPool;
27
34VoxelPool* VoxelPool_Init(SblArena* arena, uint32_t capacity);
35
46int32_t VoxelPool_AcquireSlot(VoxelPool* pool, sbgl_ivec3 pos, bool* is_new);
47
53void VoxelPool_UpdateFrame(VoxelPool* pool, uint64_t frame);
54
55#endif // VOXEL_POOL_H
Single-header math library for SBgl.
void VoxelPool_UpdateFrame(VoxelPool *pool, uint64_t frame)
Advances the pool's internal frame counter for LRU tracking.
Definition sbgl_pool.c:78
VoxelPool * VoxelPool_Init(SblArena *arena, uint32_t capacity)
Initializes a VoxelPool on the provided arena.
Definition sbgl_pool.c:10
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)....
Definition sbgl_pool.c:25
Arena allocator implementation.
Arena allocator.
Definition sbl_arena.h:47
VoxelPool manages a fixed number of slots for voxel chunks. It uses a flat array layout to maintain c...
Definition sbgl_pool.h:20
uint64_t * last_used_frames
Definition sbgl_pool.h:22
uint32_t capacity
Definition sbgl_pool.h:24
sbgl_ivec3 * positions
Definition sbgl_pool.h:21
uint64_t current_frame
Definition sbgl_pool.h:25
uint8_t * active
Definition sbgl_pool.h:23
3D integer vector for chunk coordinates.
Definition sbgl_pool.h:12
int32_t x
Definition sbgl_pool.h:13