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:
@@ -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);
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user