OpenGL VBO's: free VBO pool before redraw, otherwise this just holds onto memory

after objects are deleted until another big object is added. There's no good reason
to do this, or to think that our pool is somehow much faster than using the OpenGL
API to allocate and free buffers.
This commit is contained in:
Brecht Van Lommel
2013-08-09 19:55:43 +00:00
parent a18112249d
commit 3fbd8abcfd
3 changed files with 16 additions and 2 deletions

View File

@@ -122,6 +122,7 @@ typedef struct GPUAttrib {
} GPUAttrib;
void GPU_global_buffer_pool_free(void);
void GPU_global_buffer_pool_free_unused(void);
GPUBuffer *GPU_buffer_alloc(int size);
void GPU_buffer_free(GPUBuffer *buffer);

View File

@@ -172,6 +172,15 @@ static void gpu_buffer_pool_free(GPUBufferPool *pool)
MEM_freeN(pool);
}
static void gpu_buffer_pool_free_unused(GPUBufferPool *pool)
{
if (!pool)
return;
while (pool->totbuf)
gpu_buffer_pool_delete_last(pool);
}
static GPUBufferPool *gpu_buffer_pool = NULL;
static GPUBufferPool *gpu_get_global_buffer_pool(void)
{
@@ -188,6 +197,11 @@ void GPU_global_buffer_pool_free(void)
gpu_buffer_pool = NULL;
}
void GPU_global_buffer_pool_free_unused(void)
{
gpu_buffer_pool_free_unused(gpu_buffer_pool);
}
/* get a GPUBuffer of at least `size' bytes; uses one from the buffer
* pool if possible, otherwise creates a new one */
GPUBuffer *GPU_buffer_alloc(int size)

View File

@@ -1243,8 +1243,7 @@ void GPU_free_unused_buffers(void)
image_free_queue = NULL;
/* vbo buffers */
/* it's probably not necessary to free all buffers every frame */
/* GPU_buffer_pool_free_unused(0); */
GPU_global_buffer_pool_free_unused();
BLI_unlock_thread(LOCK_OPENGL);
}