summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2019-02-05 10:56:03 -0200
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2019-10-16 16:25:08 +0200
commitc5b7d73ce2e7650ead03932cc02047af2d007fdf (patch)
treec54468f7ff4e7137eaf7f13e8dbce025ddd436f2
parent0556138b9f731048f2c7c31c9e3a00d431ea7d9a (diff)
downloadmutter-c5b7d73ce2e7650ead03932cc02047af2d007fdf.tar.gz
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
-rw-r--r--cogl/cogl/cogl-journal-private.h1
-rw-r--r--cogl/cogl/cogl-journal.c51
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 4f7cb0f05..15de64e1b 100644
--- a/cogl/cogl/cogl-journal.c
+++ b/cogl/cogl/cogl-journal.c
@@ -1045,6 +1045,49 @@ compare_entry_clip_stacks (CoglJournalEntry *entry0, CoglJournalEntry *entry1)
}
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,
void *data)
@@ -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);