diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-15 00:21:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-15 00:44:27 +0300 |
commit | 75de653e4d6204f2fc87388a1c99abcceed04ef1 (patch) | |
tree | 90bdaff1229fcad1dacbcd3d957b7291d35c42fd /intern | |
parent | 4ecc8b67861a4869cd6b1231c1f8a1082e031ff5 (diff) |
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.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/gawain/src/gwn_batch.c | 8 |
1 files changed, 4 insertions, 4 deletions
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); } |