GWN: Extend support for multiple of 4 components in batches.
This commit is contained in:
parent
27a7174546
commit
df86e9cab5
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue