added vulkan device and queues creation

This commit is contained in:
Lorenzo Torres 2025-11-03 13:08:46 +01:00
parent 89edee7249
commit 6c31a3ce27
20 changed files with 253 additions and 18 deletions

View file

@ -2,6 +2,7 @@
#include "arena.h"
#include <stdlib.h>
struct arena_allocator *arena_init(usize size)
{
struct arena_allocator *allocator = (struct arena_allocator *) malloc(sizeof(struct arena_allocator));
@ -20,8 +21,13 @@ void arena_deinit(struct arena_allocator *allocator)
void *arena_alloc(struct arena_allocator *allocator, usize size)
{
if (allocator->position + size >= allocator->size) {
allocator->size = allocator->position + size;
allocator->base = (usize) realloc((void *)allocator->base, allocator->size + allocator->size / 2);
}
void *ptr = (void *)(allocator->base + allocator->position);
allocator->position += size;
return ptr;
}

View file

@ -17,6 +17,7 @@ struct arena_allocator {
usize position;
};
extern struct arena_allocator *global_arena;
/* Create a new arena allocator of size `size` */
struct arena_allocator *arena_init(usize size);

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "arena.h"
#define log_error_code(msg) do { printf("\x1b[31m" "[ERROR]" "\x1b[0m" "(" __FILE__ ":" __LINE__ "): %s", (msg)); } while (0)
#define log_warning_code(msg) do { printf("\x1b[33m" "[WARN]" "\x1b[0m" "(" __FILE__ ":" __LINE__ "): %s", (msg)); } while (0)
@ -13,6 +14,6 @@
#define log_warning(msg) do { printf("\x1b[33m" "[WARN]" "\x1b[0m: %s", (msg)); } while (0)
#define log_info(msg) do { printf("\x1b[32m" "[INFO]" "\x1b[0m: %s", (msg)); } while (0)
#define fatal(msg) do { log_error(msg); exit(1); } while (0)
#define fatal(msg) do { arena_bump(global_arena); arena_deinit(global_arena); log_error(msg); exit(1); } while (0)
#endif

View file

@ -4,6 +4,7 @@
struct vector *vector_init(usize size, usize element_size)
{
if (size == 0) size = 1;
struct vector *vector = (struct vector *) malloc(sizeof(struct vector));
vector->length = 0;
vector->size = size;