[Bf-blender-cvs] [ef1918d3128] blender2.8: Gawain: Fix instancing messing next draw.

Clément Foucault noreply at git.blender.org
Wed Oct 11 03:01:16 CEST 2017


Commit: ef1918d3128b1f56d69c189a838b648dc88de4c9
Author: Clément Foucault
Date:   Wed Oct 11 02:14:15 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBef1918d3128b1f56d69c189a838b648dc88de4c9

Gawain: Fix instancing messing next draw.

Everything was fine if one batch is always used with instancing. But problem arise if the next drawcall for this batch is not using instancing as the attrib divisor stays set to 1 in th VAO.

As instancing is less used than normal drawing I prefer to reset the divisor after drawing as it is reset before drawing instances.

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

M	intern/gawain/src/gwn_batch.c

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

diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
index c651fb3a26f..00448b4924d 100644
--- a/intern/gawain/src/gwn_batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -396,6 +396,10 @@ void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch, unsigned int instance_vbo
 	else
 		glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, instance_count);
 
+	// Reset divisor to prevent messing the next draw
+	for (unsigned a_idx = 0; a_idx < GWN_VERT_ATTR_MAX_LEN; ++a_idx)
+		glVertexAttribDivisor(a_idx, 0);
+
 	// GWN_batch_program_use_end(batch);
 	glBindVertexArray(0);
 	}
@@ -466,6 +470,10 @@ void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch* batch_instanced, Gwn_
 	else
 		glDrawArraysInstanced(batch_instanced->gl_prim_type, 0, batch_instanced->verts[0]->vertex_ct, verts->vertex_ct);
 
+	// Reset divisor to prevent messing the next draw
+	for (unsigned a_idx = 0; a_idx < GWN_VERT_ATTR_MAX_LEN; ++a_idx)
+		glVertexAttribDivisor(a_idx, 0);
+
 	// GWN_batch_program_use_end(batch);
 	glBindVertexArray(0);
 	}



More information about the Bf-blender-cvs mailing list