From 75de653e4d6204f2fc87388a1c99abcceed04ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 14 Mar 2018 22:21:59 +0100 Subject: GWN: Batch: Only revert to default Vao when needed. Drawing ranges via glDrawArrays is already supported and should not need a manual offset in the VAO like glDrawArraysInstanced or glDrawElements. --- intern/gawain/src/gwn_batch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'intern/gawain') diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index b7f47b316ed..b447106432c 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -529,9 +529,10 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo #if TRUST_NO_ONE assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance #endif + const bool do_instance = (force_instance || batch->inst); // If using offset drawing, use the default VAO and redo bindings. - if (v_first != 0) + if (v_first != 0 && (do_instance || batch->elem)) { glBindVertexArray(GWN_vao_default()); batch_update_program_bindings(batch, v_first); @@ -539,7 +540,7 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo else glBindVertexArray(batch->vao_id); - if (force_instance || batch->inst) + if (do_instance) { // Infer length if vertex count is not given if (v_count == 0) @@ -588,10 +589,9 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo primitive_restart_disable(); } else - glDrawArrays(batch->gl_prim_type, 0, v_count); + glDrawArrays(batch->gl_prim_type, v_first, v_count); } - glBindVertexArray(0); } -- cgit v1.2.3