diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-02-10 01:57:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-02-11 22:36:20 +0300 |
commit | 737d349dbce972459df5db03bf861c28604c3826 (patch) | |
tree | cc6eea6d3c64b183a23c219cdb75da5cacdbf4dc /source/blender/draw | |
parent | e05800d23b40a6eda0b154de934f8f8c6e1b3438 (diff) |
Clay Engine: fix instancing (again)
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0cfe75c311c..970bd2f6dee 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -334,6 +334,7 @@ static DRWInterface *DRW_interface_create(GPUShader *shader) interface->instance_count = 0; interface->attribs_count = 0; interface->attribs_stride = 0; + interface->instance_vbo = 0; memset(&interface->vbo_format, 0, sizeof(VertexFormat)); @@ -577,7 +578,6 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const /* Creates a VBO containing OGL primitives for all DRWDynamicCall */ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) { - int i = 0; DRWInterface *interface = shgroup->interface; int nbr = interface->instance_count; @@ -587,25 +587,28 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) return; /* Upload Data */ - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { - BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ - if (attrib->type == DRW_ATTRIB_FLOAT) { - attrib->format_id = add_attrib(&interface->vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); - } - else if (attrib->type == DRW_ATTRIB_INT) { - attrib->format_id = add_attrib(&interface->vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); - } - else { - BLI_assert(false); + if (interface->vbo_format.attrib_ct == 0) { + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { + BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ + if (attrib->type == DRW_ATTRIB_FLOAT) { + attrib->format_id = add_attrib(&interface->vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); + } + else if (attrib->type == DRW_ATTRIB_INT) { + attrib->format_id = add_attrib(&interface->vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); + } + else { + BLI_assert(false); + } } } VertexBuffer *vbo = VertexBuffer_create_with_format(&interface->vbo_format); VertexBuffer_allocate_data(vbo, nbr); - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { - int j = 0; - for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int j = 0; + for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int i = 0; + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { setAttrib(vbo, attrib->format_id, j, call->data[i]); } } |