Gawain : Add workaround to fix bad sync of the program_in_use flag.
authorClément Foucault <foucault.clem@gmail.com>
Mon, 2 Oct 2017 20:16:50 +0000 (22:16 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 2 Oct 2017 20:16:50 +0000 (22:16 +0200)
intern/gawain/gawain/gwn_batch.h
intern/gawain/src/gwn_batch.c
source/blender/draw/intern/draw_manager.c

index 9bcb743716371d3fba9e056842d4f8f7d95b1006..ee1599845c8a2f8ef44befc9b06b27d0a9bf1377 100644 (file)
@@ -65,6 +65,7 @@ int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo);
        GWN_batch_vertbuf_add_ex(batch, verts, false)
 
 void GWN_batch_program_set(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
+void GWN_batch_program_unset(Gwn_Batch*);
 // Entire batch draws with one shader program, but can be redrawn later with another program.
 // Vertex shader's inputs must be compatible with the batch's vertex format.
 
index 359ca956495098f7cd6a219a5a20dced137ed126..c651fb3a26ff9adca1777f3f9da976f042af30c2 100644 (file)
@@ -110,6 +110,14 @@ void GWN_batch_program_set(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInt
        GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
        }
 
+// fclem : hack !
+// we need this because we don't want to unbind the shader between drawcalls
+// but we still want the correct shader to be bound outside the draw manager
+void GWN_batch_program_unset(Gwn_Batch* batch)
+       {
+       batch->program_in_use = false;
+       }
+
 static void Batch_update_program_bindings(Gwn_Batch* batch)
        {
        // disable all as a precaution
index fab2df680ea6c03acec97a5d469cd89d23a8a702..ec22baace3ee0374462edd2e8b340d29e653b556 100644 (file)
@@ -1809,6 +1809,9 @@ static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom)
        else {
                GWN_batch_draw_stupid(geom);
        }
+       /* XXX this just tells gawain we are done with the shader.
+        * This does not unbind the shader. */
+       GWN_batch_program_unset(geom);
 }
 
 static void draw_geometry(DRWShadingGroup *shgroup, Gwn_Batch *geom, const float (*obmat)[4], ID *ob_data)