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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user