Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-05-29 17:28:54 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-05-29 17:28:54 +0300
commitec90780767721d03322d42f4c5796b7b2d03d8e3 (patch)
tree19ab9788a658281165c0822cc5223712616bad46 /source/blender
parent97e89027fc155bed061cd5ec81c5a3e6c12502cb (diff)
Gawain: Add support for rendering using an instance batch (for particles)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/intern/draw_manager.c25
-rw-r--r--source/blender/draw/modes/object_mode.c3
2 files changed, 9 insertions, 19 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 11c717a5373..cc2ad3e3017 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1133,18 +1133,11 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup)
DRWInterface *interface = shgroup->interface;
int buffer_size = 0;
- /* XXX All of this is pretty garbage. Better revisit it later. */
if (interface->instance_batch != NULL) {
- VertexBuffer *vert = interface->instance_batch->verts[0];
- /* This is double check but we don't want
- * VertexBuffer_use() to bind the buffer if it exists. */
- if (vert->vbo_id == 0) {
- VertexBuffer_use(vert);
- }
- interface->instance_vbo = vert->vbo_id;
- interface->instance_count = vert->vertex_ct;
+ return;
}
+ /* TODO We still need this because gawain does not support Matrix attribs. */
if (interface->instance_count == 0) {
if (interface->instance_vbo) {
glDeleteBuffers(1, &interface->instance_vbo);
@@ -1163,11 +1156,6 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup)
}
}
- if (interface->instance_batch != NULL) {
- /* Quit just after attribs where specified */
- return;
- }
-
/* Gather Data */
buffer_size = sizeof(float) * interface->attribs_stride * interface->instance_count;
float *data = MEM_mallocN(buffer_size, "Instance VBO data");
@@ -1611,7 +1599,10 @@ static void draw_geometry_execute(DRWShadingGroup *shgroup, Batch *geom)
DRWInterface *interface = shgroup->interface;
/* step 2 : bind vertex array & draw */
Batch_set_program(geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
- if (interface->instance_vbo) {
+ if (interface->instance_batch) {
+ Batch_draw_stupid_instanced_with_batch(geom, interface->instance_batch);
+ }
+ else if (interface->instance_vbo) {
Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
}
@@ -1737,7 +1728,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
float obmat[4][4];
unit_m4(obmat);
- if (shgroup->type == DRW_SHG_INSTANCE && interface->instance_count > 0) {
+ if (shgroup->type == DRW_SHG_INSTANCE &&
+ (interface->instance_count > 0 || interface->instance_batch != NULL))
+ {
GPU_SELECT_LOAD_IF_PICKSEL_LIST(&shgroup->calls);
draw_geometry(shgroup, shgroup->instance_geom, obmat, NULL);
}
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index f557315305d..026f0c4f275 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -1486,9 +1486,6 @@ static void OBJECT_cache_populate_particles(Object *ob,
if (shgrp) {
if (draw_as != PART_DRAW_DOT) {
- DRW_shgroup_attrib_float(shgrp, "pos", 3);
- DRW_shgroup_attrib_float(shgrp, "rot", 4);
- DRW_shgroup_attrib_float(shgrp, "val", 1);
DRW_shgroup_uniform_short_to_int(shgrp, "draw_size", &part->draw_size, 1);
DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
DRW_shgroup_instance_batch(shgrp, geom);