[Bf-blender-cvs] [0d54d32] blender2.8: Gawain: simplify attrib binding API

Mike Erwin noreply at git.blender.org
Thu Sep 15 16:51:40 CEST 2016


Commit: 0d54d32dd608be5d87d3d57131ede33a8f19aa37
Author: Mike Erwin
Date:   Thu Sep 15 12:57:07 2016 +0200
Branches: blender2.8
https://developer.blender.org/rB0d54d32dd608be5d87d3d57131ede33a8f19aa37

Gawain: simplify attrib binding API

This API is used internally by the immediate and batch drawing systems.

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

M	source/blender/gpu/gawain/attrib_binding.c
M	source/blender/gpu/gawain/attrib_binding.h

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

diff --git a/source/blender/gpu/gawain/attrib_binding.c b/source/blender/gpu/gawain/attrib_binding.c
index 05a5232..bb42aaf 100644
--- a/source/blender/gpu/gawain/attrib_binding.c
+++ b/source/blender/gpu/gawain/attrib_binding.c
@@ -11,6 +11,10 @@
 
 #include "attrib_binding.h"
 
+#if MAX_VERTEX_ATTRIBS != 16
+  #error "attrib binding code assumes MAX_VERTEX_ATTRIBS = 16"
+#endif
+
 void clear_AttribBinding(AttribBinding* binding)
 	{
 	binding->loc_bits = 0;
@@ -20,7 +24,6 @@ void clear_AttribBinding(AttribBinding* binding)
 unsigned read_attrib_location(const AttribBinding* binding, unsigned a_idx)
 	{
 #if TRUST_NO_ONE
-	assert(MAX_VERTEX_ATTRIBS == 16);
 	assert(a_idx < MAX_VERTEX_ATTRIBS);
 	assert(binding->enabled_bits & (1 << a_idx));
 #endif
@@ -28,10 +31,9 @@ unsigned read_attrib_location(const AttribBinding* binding, unsigned a_idx)
 	return (binding->loc_bits >> (4 * a_idx)) & 0xF;
 	}
 
-void write_attrib_location(AttribBinding* binding, unsigned a_idx, unsigned location)
+static void write_attrib_location(AttribBinding* binding, unsigned a_idx, unsigned location)
 	{
 #if TRUST_NO_ONE
-	assert(MAX_VERTEX_ATTRIBS == 16);
 	assert(a_idx < MAX_VERTEX_ATTRIBS);
 	assert(location < MAX_VERTEX_ATTRIBS);
 #endif
@@ -59,6 +61,7 @@ void get_attrib_locations(const VertexFormat* format, AttribBinding* binding, GL
 
 #if TRUST_NO_ONE
 		assert(loc != -1);
+		// TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program
 #endif
 
 		write_attrib_location(binding, a_idx, loc);
diff --git a/source/blender/gpu/gawain/attrib_binding.h b/source/blender/gpu/gawain/attrib_binding.h
index dfd06ce..9e2431c 100644
--- a/source/blender/gpu/gawain/attrib_binding.h
+++ b/source/blender/gpu/gawain/attrib_binding.h
@@ -20,7 +20,5 @@ typedef struct {
 
 void clear_AttribBinding(AttribBinding*);
 
-unsigned read_attrib_location(const AttribBinding*, unsigned a_idx);
-void write_attrib_location(AttribBinding*, unsigned a_idx, unsigned location);
-
 void get_attrib_locations(const VertexFormat*, AttribBinding*, GLuint program);
+unsigned read_attrib_location(const AttribBinding*, unsigned a_idx);




More information about the Bf-blender-cvs mailing list