[mutter/gbsneto/software-picking: 612/613] cogl/journal: Track dither



commit 00b1b1a6c1a0140c09491a91d09d16d2dbc0d8bb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 5 10:56:03 2019 -0200

    cogl/journal: Track dither
    
    For the exact same reason that previous commit added
    viewport tracking, also add dither state tracking and
    avoid flushing the journal even more.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/402

 cogl/cogl/cogl-journal-private.h |  1 +
 cogl/cogl/cogl-journal.c         | 51 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/cogl/cogl/cogl-journal-private.h b/cogl/cogl/cogl-journal-private.h
index 4b83e3bf2..d38c3df1a 100644
--- a/cogl/cogl/cogl-journal-private.h
+++ b/cogl/cogl/cogl-journal-private.h
@@ -79,6 +79,7 @@ typedef struct _CoglJournalEntry
   CoglMatrixEntry         *modelview_entry;
   CoglClipStack           *clip_stack;
   float                    viewport[4];
+  gboolean                 dither_enabled;
   /* Offset into ctx->logged_vertices */
   size_t                   array_offset;
   int                      n_layers;
diff --git a/cogl/cogl/cogl-journal.c b/cogl/cogl/cogl-journal.c
index d924f9a19..3c8f60670 100644
--- a/cogl/cogl/cogl-journal.c
+++ b/cogl/cogl/cogl-journal.c
@@ -1044,6 +1044,49 @@ compare_entry_clip_stacks (CoglJournalEntry *entry0, CoglJournalEntry *entry1)
   return entry0->clip_stack == entry1->clip_stack;
 }
 
+static void
+_cogl_journal_flush_dither_and_entries (CoglJournalEntry *batch_start,
+                                        int               batch_len,
+                                        void             *data)
+{
+  CoglJournalFlushState *state = data;
+  CoglFramebuffer *framebuffer = state->journal->framebuffer;
+  CoglContext *ctx = framebuffer->context;
+
+  COGL_STATIC_TIMER (time_flush_dither_and_entries,
+                     "Journal Flush", /* parent */
+                     "flush: viewport+dither+clip+vbo+texcoords+pipeline+entries",
+                     "The time spent flushing viewport + dither + clip + vbo + "
+                     "texcoord offsets + pipeline + entries",
+                     0 /* no application private data */);
+
+  COGL_TIMER_START (_cogl_uprof_context, time_flush_dither_and_entries);
+
+  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
+    g_print ("BATCHING:  dither batch len = %d\n", batch_len);
+
+  cogl_framebuffer_set_dither_enabled (framebuffer, batch_start->dither_enabled);
+  ctx->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_DITHER;
+
+  _cogl_framebuffer_flush_state (framebuffer,
+                                 framebuffer,
+                                 COGL_FRAMEBUFFER_STATE_DITHER);
+
+  batch_and_call (batch_start,
+                  batch_len,
+                  compare_entry_clip_stacks,
+                  _cogl_journal_flush_clip_stacks_and_entries,
+                  state);
+
+  COGL_TIMER_STOP (_cogl_uprof_context, time_flush_dither_and_entries);
+}
+
+static gboolean
+compare_entry_dither_states (CoglJournalEntry *entry0, CoglJournalEntry *entry1)
+{
+  return entry0->dither_enabled == entry1->dither_enabled;
+}
+
 static void
 _cogl_journal_flush_viewport_and_entries (CoglJournalEntry *batch_start,
                                           int               batch_len,
@@ -1077,8 +1120,8 @@ _cogl_journal_flush_viewport_and_entries (CoglJournalEntry *batch_start,
 
   batch_and_call (batch_start,
                   batch_len,
-                  compare_entry_clip_stacks,
-                  _cogl_journal_flush_clip_stacks_and_entries,
+                  compare_entry_dither_states,
+                  _cogl_journal_flush_dither_and_entries,
                   state);
 
   if (memcmp (batch_start->viewport, current_viewport, sizeof (float) * 4) != 0)
@@ -1385,7 +1428,8 @@ _cogl_journal_flush (CoglJournal *journal)
   _cogl_framebuffer_flush_state (framebuffer,
                                  framebuffer,
                                  COGL_FRAMEBUFFER_STATE_ALL &
-                                 ~(COGL_FRAMEBUFFER_STATE_VIEWPORT |
+                                 ~(COGL_FRAMEBUFFER_STATE_DITHER |
+                                   COGL_FRAMEBUFFER_STATE_VIEWPORT |
                                    COGL_FRAMEBUFFER_STATE_MODELVIEW |
                                    COGL_FRAMEBUFFER_STATE_CLIP));
 
@@ -1602,6 +1646,7 @@ _cogl_journal_log_quad (CoglJournal  *journal,
 
   clip_stack = _cogl_framebuffer_get_clip_stack (framebuffer);
   entry->clip_stack = _cogl_clip_stack_ref (clip_stack);
+  entry->dither_enabled = cogl_framebuffer_get_dither_enabled (framebuffer);
 
   cogl_framebuffer_get_viewport4fv (framebuffer, entry->viewport);
 


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