From df86e9cab54fe1272697bb652436f46937fc0886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sun, 11 Feb 2018 15:33:39 +0100 Subject: GWN: Extend support for multiple of 4 components in batches. --- intern/gawain/gawain/gwn_vertex_format.h | 2 +- intern/gawain/src/gwn_batch.c | 4 ++-- intern/gawain/src/gwn_vertex_format.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'intern/gawain') 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 -- cgit v1.2.3