diff options
| author | Clement Sibille <clements@lisible.xyz> | 2025-05-05 08:32:33 +0200 |
|---|---|---|
| committer | Clement Sibille <clements@lisible.xyz> | 2025-05-05 12:24:27 +0200 |
| commit | b71eac2069a30349435c192d682e865718c86a15 (patch) | |
| tree | 33754245a23533e31e6a83390bf190c11dfe2bb9 /src/alloc.h | |
| parent | 6017db0069977ae85e698a1234f4a2b7632ee495 (diff) | |
Add a vulkan renderer that renders an OBJ
Diffstat (limited to 'src/alloc.h')
| -rw-r--r-- | src/alloc.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/alloc.h b/src/alloc.h new file mode 100644 index 0000000..bde1d55 --- /dev/null +++ b/src/alloc.h @@ -0,0 +1,40 @@ +#ifndef VGLTF_ALLOC_H +#define VGLTF_ALLOC_H + +#include <stddef.h> + +struct vgltf_allocator { + void *(*allocate)(size_t size, void *ctx); + void *(*allocate_aligned)(size_t alignment, size_t size, void *ctx); + void *(*allocate_array)(size_t count, size_t item_size, void *ctx); + void *(*reallocate)(void *ptr, size_t old_size, size_t new_size, void *ctx); + void (*free)(void *ptr, void *ctx); + void *ctx; +}; + +void *vgltf_allocator_allocate(struct vgltf_allocator *allocator, size_t size); +void *vgltf_allocator_allocate_aligned(struct vgltf_allocator *allocator, + size_t alignment, size_t size); +void *vgltf_allocator_allocate_array(struct vgltf_allocator *allocator, + size_t count, size_t item_size); +void *vgltf_allocator_reallocate(struct vgltf_allocator *allocator, void *ptr, + size_t old_size, size_t new_size); +void vgltf_allocator_free(struct vgltf_allocator *allocator, void *ptr); + +extern thread_local struct vgltf_allocator system_allocator; + +struct vgltf_arena { + size_t capacity; + size_t size; + char *data; +}; +void vgltf_arena_init(struct vgltf_allocator *allocator, struct vgltf_arena *arena, + size_t size); +void vgltf_arena_deinit(struct vgltf_allocator *allocator, struct vgltf_arena *arena); +void *vgltf_arena_allocate(struct vgltf_arena *arena, size_t size); +void *vgltf_arena_allocate_array(struct vgltf_arena *arena, size_t count, + size_t item_size); +void vgltf_arena_reset(struct vgltf_arena *arena); +struct vgltf_allocator vgltf_arena_allocator(struct vgltf_arena *arena); + +#endif // VGLTF_ALLOC_H |
