[gtk/wip/chergert/glproto: 214/493] simple batch merging




commit 4beaffbb9b673ae79cde0dec8970bcc130e0dc81
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 20 11:30:09 2021 -0800

    simple batch merging
    
    this only tries to chain on to the last batch. it will need to be more
    advanced as we do out-of-order batching later on, but this gets a number
    of character nodes to batch together now

 gsk/next/gskglcommandqueue.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 77854e7e2b..6e98e54718 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -365,12 +365,18 @@ gsk_gl_command_queue_uniform_snapshot_cb (const GskGLUniformInfo *info,
 void
 gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
 {
+  GskGLCommandBatch *last_batch;
   GskGLCommandBatch *batch;
 
   g_return_if_fail (GSK_IS_GL_COMMAND_QUEUE (self));
   g_return_if_fail (self->batches->len > 0);
   g_return_if_fail (self->in_draw == TRUE);
 
+  if (self->batches->len > 1)
+    last_batch = &g_array_index (self->batches, GskGLCommandBatch, self->batches->len - 2);
+  else
+    last_batch = NULL;
+
   batch = &g_array_index (self->batches, GskGLCommandBatch, self->batches->len - 1);
 
   g_assert (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW);
@@ -416,7 +422,25 @@ gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
         }
     }
 
-  enqueue_batch (self);
+  /* Do simple chaining of draw to last batch. */
+  /* TODO: Use merging capabilities for out-or-order batching */
+  if (last_batch != NULL &&
+      last_batch->any.kind == GSK_GL_COMMAND_KIND_DRAW &&
+      last_batch->any.program == batch->any.program &&
+      last_batch->any.viewport.width == batch->any.viewport.width &&
+      last_batch->any.viewport.height == batch->any.viewport.height &&
+      last_batch->draw.framebuffer == batch->draw.framebuffer &&
+      batch->draw.uniform_count == 0 &&
+      batch->draw.bind_count == 0 &&
+      last_batch->draw.vbo_offset + last_batch->draw.vbo_count == batch->draw.vbo_offset)
+    {
+      last_batch->draw.vbo_count += batch->draw.vbo_count;
+      discard_batch (self);
+    }
+  else
+    {
+      enqueue_batch (self);
+    }
 
   self->in_draw = FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]