[Bf-blender-cvs] [e7fc8d9] master: Failure to alllocate vertex buffer would not fall back to vertex array properly.

Antony Riakiotakis noreply at git.blender.org
Tue Jul 21 15:42:27 CEST 2015


Commit: e7fc8d98f5eb28d26d9a2a6be816dc5e57a1d678
Author: Antony Riakiotakis
Date:   Tue Jul 21 15:41:57 2015 +0200
Branches: master
https://developer.blender.org/rBe7fc8d98f5eb28d26d9a2a6be816dc5e57a1d678

Failure to alllocate vertex buffer would not fall back to vertex array
properly.

This should fix failure to use vertex arrays in OSX with high
polycounts.

Note this will not suffice as a fix when we move to VBOs exclusively
(GL 3+), we'll have to think of some way to separate huge meshes to many
VBOs.

===================================================================

M	source/blender/gpu/intern/gpu_buffers.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 4920635..4691659 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -327,8 +327,10 @@ static GPUBuffer *gpu_buffer_alloc_intern(size_t size, bool use_VBO)
 			gpu_buffer_pool_delete_last(pool);
 			buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer");
 		}
-		if (!buf->pointer)
+		if (!buf->pointer) {
+			MEM_freeN(buf);
 			return NULL;
+		}
 	}
 
 	return buf;
@@ -473,17 +475,17 @@ void GPU_drawobject_free(DerivedMesh *dm)
 
 static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size, bool use_VBOs)
 {
-	gpu_buffer_free_intern(buffer);
-	gpu_buffer_pool_delete_last(pool);
-	buffer = NULL;
-	
 	/* try freeing an entry from the pool
 	 * and reallocating the buffer */
-	if (pool->totbuf > 0) {
+	gpu_buffer_free_intern(buffer);
+
+	buffer = NULL;
+
+	while (pool->totbuf && !buffer) {
 		gpu_buffer_pool_delete_last(pool);
 		buffer = gpu_buffer_alloc_intern(size, use_VBOs);
 	}
-	
+
 	return buffer;
 }




More information about the Bf-blender-cvs mailing list