From 2bccc4bf080bf1872dfe0f47847e342eab5b6622 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 26 Jan 2023 21:44:01 -0800 Subject: [PATCH] Increase max size of vector pool; 16k vec3s -> 4 million vec3s --- src/modules/math/pool.c | 14 +++++++------- src/modules/math/pool.h | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/modules/math/pool.c b/src/modules/math/pool.c index b56b57c1..ffaa2f9c 100644 --- a/src/modules/math/pool.c +++ b/src/modules/math/pool.c @@ -13,9 +13,9 @@ static const size_t vectorComponents[] = { struct Pool { uint32_t ref; float* data; - size_t count; - size_t cursor; - size_t generation; + uint32_t count; + uint32_t cursor; + uint32_t generation; }; Pool* lovrPoolCreate() { @@ -33,7 +33,7 @@ void lovrPoolDestroy(void* ref) { } 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->data = realloc(pool->data, pool->count * sizeof(float)); lovrAssert(pool->data, "Out of memory"); @@ -49,8 +49,8 @@ Vector lovrPoolAllocate(Pool* pool, VectorType type, float** data) { Vector v = { .handle = { .type = type, - .generation = (uint8_t) pool->generation, - .index = (uint16_t) pool->cursor + .generation = pool->generation, + .index = pool->cursor } }; @@ -66,5 +66,5 @@ float* lovrPoolResolve(Pool* pool, Vector vector) { void lovrPoolDrain(Pool* pool) { pool->cursor = 0; - pool->generation = (pool->generation + 1) & 0xff; + pool->generation = (pool->generation + 1) & 0xf; } diff --git a/src/modules/math/pool.h b/src/modules/math/pool.h index b8882d7a..92218dc8 100644 --- a/src/modules/math/pool.h +++ b/src/modules/math/pool.h @@ -16,10 +16,10 @@ typedef enum { typedef union { void* pointer; struct { - uint8_t type; - uint8_t generation; - uint16_t index; - uint32_t padding; + unsigned index : 24; + unsigned type : 4; + unsigned generation : 4; + unsigned padding : 32; } handle; } Vector;