[Bf-blender-cvs] [c402a37] master: Remove vertex array support from GPUBuffers. Remove USER_DISABLE_VBO. All GPUBuffer rendering is now done using vertex buffers.

Antony Riakiotakis noreply at git.blender.org
Sun Nov 22 19:48:26 CET 2015


Commit: c402a379a23af71aa5c21566967b75ab5c869e01
Author: Antony Riakiotakis
Date:   Sun Nov 22 19:46:31 2015 +0100
Branches: master
https://developer.blender.org/rBc402a379a23af71aa5c21566967b75ab5c869e01

Remove vertex array support from GPUBuffers. Remove USER_DISABLE_VBO. All
GPUBuffer rendering is now done using vertex buffers.

Vertex arrays are completely removed from GL 3.2 core profile, so we'll
have to do this change at some point anyway.

This commit, though big, is not modifying blender in any way. Use should
be exactly as if the vetex buffer option is constantly on.

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/editors/interface/resources.c
M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 1259e74..bee9d84 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -461,7 +461,6 @@ class USERPREF_PT_system(Panel):
 
         col.label(text="Anisotropic Filtering")
         col.prop(system, "anisotropic_filter", text="")
-        col.prop(system, "use_vertex_buffer_objects")
 
         col.separator()
 
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index be4f001..b925094 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -665,7 +665,7 @@ static void cdDM_drawMappedFaces(
 			else
 				me = userData;
 
-			findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int), false);
+			findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int));
 			fi_map = GPU_buffer_lock(findex_buffer, GPU_BINDING_ARRAY);
 
 			if (fi_map) {
@@ -898,9 +898,7 @@ static void cdDM_drawMappedFacesGLSL(
 
 	glShadeModel(GL_SMOOTH);
 
-	/* workaround for NVIDIA GPUs on Mac not supporting vertex arrays + interleaved formats, see T43342 */
-	if ((GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY) && (U.gameflags & USER_DISABLE_VBO)) ||
-	    setDrawOptions != NULL)
+	if (setDrawOptions != NULL)
 	{
 		DMVertexAttribs attribs;
 		DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n");
@@ -1037,11 +1035,8 @@ static void cdDM_drawMappedFacesGLSL(
 
 		/* part two, generate and fill the arrays with the data */
 		if (max_element_size > 0) {
-			buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, false);
+			buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts);
 
-			if (buffer == NULL) {
-				buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, true);
-			}
 			varray = GPU_buffer_lock_stream(buffer, GPU_BINDING_ARRAY);
 			if (varray == NULL) {
 				GPU_buffers_unbind();
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 5814a06..b7742d8 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2808,9 +2808,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
 	CCG_key_top_level(&key, ss);
 	ccgdm_pbvh_update(ccgdm);
 
-	/* workaround for NVIDIA GPUs on Mac not supporting vertex arrays + interleaved formats, see T43342 */
-	if ((GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY) && (U.gameflags & USER_DISABLE_VBO)) ||
-	        setDrawOptions != NULL)
+	if (setDrawOptions != NULL)
 	{
 		const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
 		DMVertexAttribs attribs = {{{NULL}}};
@@ -3029,11 +3027,8 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
 
 		/* part two, generate and fill the arrays with the data */
 		if (max_element_size > 0) {
-			buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, false);
+			buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts);
 
-			if (buffer == NULL) {
-				buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, true);
-			}
 			varray = GPU_buffer_lock_stream(buffer, GPU_BINDING_ARRAY);
 			if (varray == NULL) {
 				GPU_buffers_unbind();
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 92ef0d0..294aa6c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1939,10 +1939,6 @@ void init_userdef_do_versions(void)
 		if (U.audiorate == 0)
 			U.audiorate = 44100;
 	}
-
-	if (!USER_VERSION_ATLEAST(250, 3)) {
-		U.gameflags |= USER_DISABLE_VBO;
-	}
 	
 	if (!USER_VERSION_ATLEAST(250, 8)) {
 		wmKeyMap *km;
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index e653af0..9c67f40 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -54,9 +54,7 @@ struct MVert;
 
 typedef struct GPUBuffer {
 	size_t size;        /* in bytes */
-	void *pointer;   /* used with vertex arrays */
 	unsigned int id; /* used with vertex buffer objects */
-	bool use_vbo;    /* true for VBOs, false for vertex arrays */
 } GPUBuffer;
 
 typedef struct GPUBufferMaterial {
@@ -156,7 +154,7 @@ typedef struct GPUAttrib {
 void GPU_global_buffer_pool_free(void);
 void GPU_global_buffer_pool_free_unused(void);
 
-GPUBuffer *GPU_buffer_alloc(size_t size, bool force_vertex_arrays);
+GPUBuffer *GPU_buffer_alloc(size_t size);
 void GPU_buffer_free(GPUBuffer *buffer);
 
 void GPU_drawobject_free(struct DerivedMesh *dm);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index eeefa92..69aca31 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -209,10 +209,7 @@ static void gpu_buffer_pool_delete_last(GPUBufferPool *pool)
 		return;
 
 	/* delete the buffer's data */
-	if (last->use_vbo)
-		glDeleteBuffers(1, &last->id);
-	else
-		MEM_freeN(last->pointer);
+	glDeleteBuffers(1, &last->id);
 
 	/* delete the buffer and remove from pool */
 	MEM_freeN(last);
@@ -273,7 +270,7 @@ void GPU_global_buffer_pool_free_unused(void)
  *
  * Thread-unsafe version for internal usage only.
  */
-static GPUBuffer *gpu_buffer_alloc_intern(size_t size, bool use_VBO)
+static GPUBuffer *gpu_buffer_alloc_intern(size_t size)
 {
 	GPUBufferPool *pool;
 	GPUBuffer *buf;
@@ -298,11 +295,6 @@ static GPUBuffer *gpu_buffer_alloc_intern(size_t size, bool use_VBO)
 	 * twice as big */
 	for (i = 0; i < pool->totbuf; i++) {
 		bufsize = pool->buffers[i]->size;
-
-		/* only return a buffer that matches the VBO preference */
-		if (pool->buffers[i]->use_vbo != use_VBO) {
-			 continue;
-		}
 		
 		/* check for an exact size match */
 		if (bufsize == size) {
@@ -332,45 +324,19 @@ static GPUBuffer *gpu_buffer_alloc_intern(size_t size, bool use_VBO)
 	/* no acceptable buffer found in the pool, create a new one */
 	buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer");
 	buf->size = size;
-	buf->use_vbo = use_VBO;
-
-	if (use_VBO) {
-		/* create a new VBO and initialize it to the requested
-		 * size */
-		glGenBuffers(1, &buf->id);
-		glBindBuffer(GL_ARRAY_BUFFER, buf->id);
-		glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	else {
-		static int time = 0;
-
-		buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer");
 
-		time++;
-		/* purpose of this seems to be dealing with
-		 * out-of-memory errors? looks a bit iffy to me
-		 * though, at least on Linux I expect malloc() would
-		 * just overcommit. --nicholas */
-		while (!buf->pointer && pool->totbuf > 0) {
-			gpu_buffer_pool_delete_last(pool);
-			buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer");
-		}
-		if (!buf->pointer) {
-			MEM_freeN(buf);
-			return NULL;
-		}
-	}
+	glGenBuffers(1, &buf->id);
+	glBindBuffer(GL_ARRAY_BUFFER, buf->id);
+	glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
 
 	return buf;
 }
 
 /* Same as above, but safe for threading. */
-GPUBuffer *GPU_buffer_alloc(size_t size, bool force_vertex_arrays)
+GPUBuffer *GPU_buffer_alloc(size_t size)
 {
 	GPUBuffer *buffer;
-	bool use_VBOs = !(U.gameflags & USER_DISABLE_VBO) && !force_vertex_arrays;
-	/* TODO: remove USER_DISABLE_VBO from user prefs */
 
 	if (size == 0) {
 		/* Early out, no lock needed in this case. */
@@ -378,7 +344,7 @@ GPUBuffer *GPU_buffer_alloc(size_t size, bool force_vertex_arrays)
 	}
 
 	BLI_mutex_lock(&buffer_mutex);
-	buffer = gpu_buffer_alloc_intern(size, use_VBOs);
+	buffer = gpu_buffer_alloc_intern(size);
 	BLI_mutex_unlock(&buffer_mutex);
 
 	return buffer;
@@ -453,8 +419,6 @@ void GPU_buffer_multires_free(bool force)
 		if (mres_glob_buffer) {
 			if (mres_glob_buffer->id)
 				glDeleteBuffers(1, &mres_glob_buffer->id);
-			else if (mres_glob_buffer->pointer)
-				MEM_freeN(mres_glob_buffer->pointer);
 			MEM_freeN(mres_glob_buffer);
 		}
 	}
@@ -503,7 +467,7 @@ void GPU_drawobject_free(DerivedMesh *dm)
 	dm->drawObject = NULL;
 }
 
-static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size, bool use_VBOs)
+static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size)
 {
 	/* try freeing an entry from the pool
 	 * and reallocating the buffer */
@@ -513,7 +477,7 @@ static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t
 
 	while (pool->totbuf && !buffer) {
 		gpu_buffer_pool_delete_last(pool);
-		buffer = gpu_buffer_alloc_intern(size, use_VBOs);
+		buffer = gpu_buffer_alloc_intern(size);
 	}
 
 	return buffer;
@@ -530,8 +494,6 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
 	const GPUBufferTypeSettings *ts = &gpu_buffer_type_settings[type];
 	GLenum target = ts->gl_buffer_type;
 	size_t size = gpu_buffer_size_from_type(dm, type);
-	bool use_VBOs = !(U.gameflags & USER_DISABLE_VBO);
-	/* TODO: remove USER_DISABLE_VBO from user prefs */
 	GLboolean uploaded;
 
 	pool = gpu_get_global_buffer_pool();
@@ -539,7 +501,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
 	BLI_mutex_lock(&buffer_mutex);
 
 	/* alloc a GPUBuffer; fall back to legacy mode on failure */
-	if (!(buffer = gpu_buffer_alloc_intern(size, use_VBOs))) {
+	if (!(buffer = gpu_buffer_alloc_intern(size))) {
 		BLI_mutex_unlock(&buffer_mutex);
 		return NULL;
 	}
@@ -552,56 +514,34 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
 		mat_orig_to_new[object->materials[i].mat_nr] = i;
 	}
 
-	if (use_VBOs) {
-		bool success = false;
+	/* bind the buffer and discard previous data,
+	 * avoids stalling gpu */
+	glBindBuffer(target, buffer->id);
+	glBufferData(target, buffer->size, NULL, GL_STATIC_DRAW);
 
-		while (!success) {
-			/* bind the buffer and discard previous data,
-			 * avoids stalling gpu */
-			glBindBuffer(target, buffer->id);
-			glBufferData(target, buffer->size, NULL, GL_STATIC_DRAW);
+	/* 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list