[Bf-blender-cvs] [77619f52740] master: GPU: Fix huge performance regression regarding instancing

Clément Foucault noreply at git.blender.org
Tue Feb 18 18:20:06 CET 2020


Commit: 77619f527403608a349b3037d18f71893d4484d1
Author: Clément Foucault
Date:   Tue Feb 18 18:19:12 2020 +0100
Branches: master
https://developer.blender.org/rB77619f527403608a349b3037d18f71893d4484d1

GPU: Fix huge performance regression regarding instancing

Under some circumstances, MultiDrawIndirect was disabled to improve perf.
of average scene. But this conflicted with the normal instancing buffer
filling if only 1 or 2 instances were needed to fill the buffer. All
consecutive drawcalls could not be batched together and performance would
degrade rapidly.

This patch make my instance test scene go from 11fps back to 40fps where
it should have been.

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

M	source/blender/gpu/intern/gpu_batch.c

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

diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 75989db9ecf..731407a64f9 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -919,8 +919,12 @@ void GPU_draw_list_submit(GPUDrawList *list)
 
   /* Only do multi-draw indirect if doing more than 2 drawcall.
    * This avoids the overhead of buffer mapping if scene is
-   * not very instance friendly. */
-  if (USE_MULTI_DRAW_INDIRECT && cmd_len > 2) {
+   * not very instance friendly.
+   * BUT we also need to take into account the case where only
+   * a few instances are needed to finish filling a call buffer. */
+  const bool do_mdi = (cmd_len > 2) || (list->cmd_offset + bytes_used == list->buffer_size);
+
+  if (USE_MULTI_DRAW_INDIRECT && do_mdi) {
     GLenum prim = batch->gl_prim_type;
 
     glBindBuffer(GL_DRAW_INDIRECT_BUFFER, list->buffer_id);



More information about the Bf-blender-cvs mailing list