1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-04 21:43:34 +00:00

Increase max size of vector pool;

16k vec3s -> 4 million vec3s
This commit is contained in:
bjorn 2023-01-26 21:44:01 -08:00
parent 132b8d6003
commit 2bccc4bf08
2 changed files with 11 additions and 11 deletions

View file

@ -13,9 +13,9 @@ static const size_t vectorComponents[] = {
struct Pool { struct Pool {
uint32_t ref; uint32_t ref;
float* data; float* data;
size_t count; uint32_t count;
size_t cursor; uint32_t cursor;
size_t generation; uint32_t generation;
}; };
Pool* lovrPoolCreate() { Pool* lovrPoolCreate() {
@ -33,7 +33,7 @@ void lovrPoolDestroy(void* ref) {
} }
void lovrPoolGrow(Pool* pool, size_t count) { void lovrPoolGrow(Pool* pool, size_t count) {
lovrAssert(count <= (1 << 16), "Temporary vector space exhausted. Try using lovr.math.drain to drain the vector pool periodically."); lovrAssert(count <= (1 << 24), "Temporary vector space exhausted. Try using lovr.math.drain to drain the vector pool periodically.");
pool->count = count; pool->count = count;
pool->data = realloc(pool->data, pool->count * sizeof(float)); pool->data = realloc(pool->data, pool->count * sizeof(float));
lovrAssert(pool->data, "Out of memory"); lovrAssert(pool->data, "Out of memory");
@ -49,8 +49,8 @@ Vector lovrPoolAllocate(Pool* pool, VectorType type, float** data) {
Vector v = { Vector v = {
.handle = { .handle = {
.type = type, .type = type,
.generation = (uint8_t) pool->generation, .generation = pool->generation,
.index = (uint16_t) pool->cursor .index = pool->cursor
} }
}; };
@ -66,5 +66,5 @@ float* lovrPoolResolve(Pool* pool, Vector vector) {
void lovrPoolDrain(Pool* pool) { void lovrPoolDrain(Pool* pool) {
pool->cursor = 0; pool->cursor = 0;
pool->generation = (pool->generation + 1) & 0xff; pool->generation = (pool->generation + 1) & 0xf;
} }

View file

@ -16,10 +16,10 @@ typedef enum {
typedef union { typedef union {
void* pointer; void* pointer;
struct { struct {
uint8_t type; unsigned index : 24;
uint8_t generation; unsigned type : 4;
uint16_t index; unsigned generation : 4;
uint32_t padding; unsigned padding : 32;
} handle; } handle;
} Vector; } Vector;