diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-09 23:55:43 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-09 23:55:43 +0400 |
commit | 3fbd8abcfd01b3e8b47bfc8420e2be5fca50036c (patch) | |
tree | 57de0e031f293623a051e62b19bd770bab988bc9 /source/blender | |
parent | a18112249d826046fd7d8692571a0eab5bb5ec04 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/GPU_buffers.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 14 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 3 |
3 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 9f6f80585ab..fca8dcc3392 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -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); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 11cf64b0995..c54f937f4a9 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -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) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 9dc98e59c42..e9f9d4a3379 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -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); } |