[Bf-blender-cvs] [df86e9cab54] blender2.8: GWN: Extend support for multiple of 4 components in batches.

Clément Foucault noreply at git.blender.org
Wed Feb 14 19:02:31 CET 2018


Commit: df86e9cab54fe1272697bb652436f46937fc0886
Author: Clément Foucault
Date:   Sun Feb 11 15:33:39 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBdf86e9cab54fe1272697bb652436f46937fc0886

GWN: Extend support for multiple of 4 components in batches.

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

M	intern/gawain/gawain/gwn_vertex_format.h
M	intern/gawain/src/gwn_batch.c
M	intern/gawain/src/gwn_vertex_format.c

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

diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h
index 45c86498172..911c0605ecc 100644
--- a/intern/gawain/gawain/gwn_vertex_format.h
+++ b/intern/gawain/gawain/gwn_vertex_format.h
@@ -41,7 +41,7 @@ typedef enum {
 typedef struct Gwn_VertAttr {
 	Gwn_VertCompType comp_type;
 	unsigned gl_comp_type;
-	unsigned comp_ct; // 1 to 4 or 16
+	unsigned comp_ct; // 1 to 4 or 8 or 12 or 16
 	unsigned sz; // size in bytes, 1 to 64
 	unsigned offset; // from beginning of vertex, in bytes
 	Gwn_VertFetchMode fetch_mode;
diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
index c15591abc79..ee6de9d1126 100644
--- a/intern/gawain/src/gwn_batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -145,13 +145,13 @@ static void create_bindings(Gwn_Batch* batch, const Gwn_ShaderInterface* interfa
 
 				if (input == NULL) continue;
 
-				if (a->comp_ct == 16) // Mat4 case
+				if (a->comp_ct == 16 || a->comp_ct == 12 || a->comp_ct == 8)
 					{
 #if TRUST_NO_ONE
 					assert(a->fetch_mode == GWN_FETCH_FLOAT);
 					assert(a->gl_comp_type == GL_FLOAT);
 #endif
-					for (int i = 0; i < 4; ++i)
+					for (int i = 0; i < a->comp_ct / 4; ++i)
 						{
 						glEnableVertexAttribArray(input->location + i);
 						glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0);
diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c
index ff534673294..4694bc22b2b 100644
--- a/intern/gawain/src/gwn_vertex_format.c
+++ b/intern/gawain/src/gwn_vertex_format.c
@@ -136,7 +136,7 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V
 	assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
 	assert(format->attrib_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
 	assert(!format->packed); // packed means frozen/locked
-	assert((comp_ct >= 1 && comp_ct <= 4) || comp_ct == 16);
+	assert((comp_ct >= 1 && comp_ct <= 4) || comp_ct == 8 || comp_ct == 12 || comp_ct == 16);
 	switch (comp_type)
 		{
 		case GWN_COMP_F32:
@@ -153,7 +153,7 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V
 			// integer types can be kept as int or converted/normalized to float
 			assert(fetch_mode != GWN_FETCH_FLOAT);
 			// only support float matrices (see Batch_update_program_bindings)
-			assert(comp_ct != 16);
+			assert(comp_ct != 8 && comp_ct != 12 && comp_ct != 16);
 		}
 #endif
 	format->name_ct++; // multiname support



More information about the Bf-blender-cvs mailing list