[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59035] trunk/blender/source/blender/gpu: OpenGL VBO's: free VBO pool before redraw, otherwise this just holds onto memory

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Aug 9 21:55:43 CEST 2013


Revision: 59035
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59035
Author:   blendix
Date:     2013-08-09 19:55:43 +0000 (Fri, 09 Aug 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/gpu/GPU_buffers.h
    trunk/blender/source/blender/gpu/intern/gpu_buffers.c
    trunk/blender/source/blender/gpu/intern/gpu_draw.c

Modified: trunk/blender/source/blender/gpu/GPU_buffers.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_buffers.h	2013-08-09 18:47:25 UTC (rev 59034)
+++ trunk/blender/source/blender/gpu/GPU_buffers.h	2013-08-09 19:55:43 UTC (rev 59035)
@@ -122,6 +122,7 @@
 } 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);

Modified: trunk/blender/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_buffers.c	2013-08-09 18:47:25 UTC (rev 59034)
+++ trunk/blender/source/blender/gpu/intern/gpu_buffers.c	2013-08-09 19:55:43 UTC (rev 59035)
@@ -172,6 +172,15 @@
 	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 @@
 	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)

Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c	2013-08-09 18:47:25 UTC (rev 59034)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c	2013-08-09 19:55:43 UTC (rev 59035)
@@ -1243,8 +1243,7 @@
 	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);
 }




More information about the Bf-blender-cvs mailing list