[Bf-blender-cvs] [09076e4] GPU_data_request: check extensions before use in GPUx

Mike Erwin noreply at git.blender.org
Mon Apr 27 20:56:14 CEST 2015


Commit: 09076e4f99f2039029e0037067080cf02235310c
Author: Mike Erwin
Date:   Mon Apr 27 14:55:26 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB09076e4f99f2039029e0037067080cf02235310c

check extensions before use in GPUx

Using VAOs and integer vertex attributes.

VBO support is *not* checked because it’s guaranteed to be there in a
GL 2.1 context.

VAOs are not part of GL 2.1, but enjoy nearly universal support.

gpu_shader4 is widely supported on recent hardware, not always on older
HW.

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

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

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

diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 84eb97d..84d2697 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -1,6 +1,7 @@
 
 #include "GPUx_vbo.h"
 #include "gpux_buffer_id.h"
+#include "GPU_extensions.h"
 #include "BLI_utildefines.h"
 #include "MEM_guardedalloc.h"
 #include <string.h>
@@ -145,10 +146,14 @@ void GPUx_attrib_print(const VertexBuffer *buff, unsigned attrib_num)
 
 VertexBuffer *GPUx_vertex_buffer_create(unsigned a_ct, unsigned v_ct)
 {
-	VertexBuffer *buff = MEM_callocN(offsetof(VertexBuffer, attribs) + a_ct * sizeof(Attrib), "VertexBuffer");
+	VertexBuffer *buff;
 #ifdef TRUST_NO_ONE
 	BLI_assert(a_ct >= 1 && a_ct <= 16);
+  #ifdef USE_VAO
+	BLI_assert(GPU_vertex_array_object_support());
+  #endif /* USE_VBO */
 #endif /* TRUST_NO_ONE */
+	buff = MEM_callocN(offsetof(VertexBuffer, attribs) + a_ct * sizeof(Attrib), "VertexBuffer");
 	buff->attrib_ct = a_ct;
 	buff->vertex_ct = v_ct;
 	return buff;
@@ -217,8 +222,11 @@ void GPUx_specify_attrib(VertexBuffer *buff, unsigned attrib_num,
 
 	if (comp_type == GL_FLOAT)
 		BLI_assert(fetch_mode == KEEP_FLOAT);
-	else
+	else {
 		BLI_assert(fetch_mode != KEEP_FLOAT);
+		if (fetch_mode == KEEP_INT)
+			BLI_assert(GPU_shader4_support());
+	}
 
   #ifndef GENERIC_ATTRIB
 	/* classic (non-generic) attributes each have their quirks




More information about the Bf-blender-cvs mailing list