[gtk/wip/chergert/glproto: 509/526] bring batch glyph vertices batching




commit 806356e731cb434823e71faeb097c8dae98111c0
Author: Christian Hergert <chergert redhat com>
Date:   Thu Feb 11 17:00:47 2021 -0800

    bring batch glyph vertices batching
    
    by incrementing the vbo_count manually, we can still do batching of the
    array growth/calculations.

 gsk/next/gskglcommandqueueprivate.h | 15 +++++++++++++--
 gsk/next/gskglrenderjob.c           |  4 +++-
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueueprivate.h b/gsk/next/gskglcommandqueueprivate.h
index 9bb799db07..90c2f5acb5 100644
--- a/gsk/next/gskglcommandqueueprivate.h
+++ b/gsk/next/gskglcommandqueueprivate.h
@@ -311,6 +311,12 @@ void               gsk_gl_command_queue_begin_draw           (GskGLCommandQueue
 void               gsk_gl_command_queue_end_draw             (GskGLCommandQueue        *self);
 void               gsk_gl_command_queue_split_draw           (GskGLCommandQueue        *self);
 
+static inline GskGLCommandBatch *
+gsk_gl_command_queue_get_batch (GskGLCommandQueue *self)
+{
+  return &self->batches[self->n_batches - 1];
+}
+
 static inline GskGLDrawVertex *
 gsk_gl_command_queue_add_vertices (GskGLCommandQueue *self)
 {
@@ -322,7 +328,10 @@ static inline GskGLDrawVertex *
 gsk_gl_command_queue_add_n_vertices (GskGLCommandQueue *self,
                                      guint              count)
 {
-  self->batches[self->n_batches - 1].draw.vbo_count += GSK_GL_N_VERTICES * count;
+  /* This is a batch form of gsk_gl_command_queue_add_vertices(). Note that
+   * it does *not* add the count to .draw.vbo_count as the caller is responsible
+   * for that.
+   */
   return gsk_gl_buffer_advance (&self->vertices, GSK_GL_N_VERTICES * count);
 }
 
@@ -330,7 +339,9 @@ static inline void
 gsk_gl_command_queue_retract_n_vertices (GskGLCommandQueue *self,
                                          guint              count)
 {
-  self->batches[self->n_batches - 1].draw.vbo_count -= GSK_GL_N_VERTICES * count;
+  /* Like gsk_gl_command_queue_add_n_vertices(), this does not tweak
+   * the draw vbo_count.
+   */
   gsk_gl_buffer_retract (&self->vertices, GSK_GL_N_VERTICES * count);
 }
 
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index b7f6407169..0f88ce9d37 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -2592,7 +2592,6 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob      *job,
         goto next;
 
       base = used * GSK_GL_N_VERTICES;
-      used++;
 
       texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (glyph);
 
@@ -2650,6 +2649,9 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob      *job,
       vertices[base+5].uv[0] = tx2;
       vertices[base+5].uv[1] = ty;
 
+      gsk_gl_command_queue_get_batch (job->command_queue)->draw.vbo_count += GSK_GL_N_VERTICES;
+      used++;
+
 next:
       x_position += gi->geometry.width;
     }


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