cogl-vertex-attribute: Optionally avoid applying the legacy state

When an item is added to the journal the current pipeline immediately
gets the legacy state applied to it and the modified pipeline is
logged instead of the original. However the actual drawing from the
journal is done using the vertex attribute API which was also applying
the legacy state. This meant that the legacy state used would be a
combination of the state set when the journal entry was added as well
as the state set when the journal is flushed. To fix this there is now
an extra CoglDrawFlag to avoid applying the legacy state when setting
up the GL state for the vertex attributes. The journal uses this flag
when flushing.
This commit is contained in:
Neil Roberts 2011-01-10 20:13:41 +00:00
parent cb49197d01
commit 38e527a3cf
3 changed files with 11 additions and 4 deletions

View File

@ -235,7 +235,8 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
CoglVertexAttribute **attributes; CoglVertexAttribute **attributes;
CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH | CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH |
COGL_DRAW_SKIP_PIPELINE_VALIDATION | COGL_DRAW_SKIP_PIPELINE_VALIDATION |
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
COGL_DRAW_SKIP_LEGACY_STATE);
COGL_STATIC_TIMER (time_flush_modelview_and_entries, COGL_STATIC_TIMER (time_flush_modelview_and_entries,
"flush: pipeline+entries", /* parent */ "flush: pipeline+entries", /* parent */

View File

@ -62,13 +62,17 @@ typedef enum
COGL_DRAW_SKIP_JOURNAL_FLUSH = 1 << 0, COGL_DRAW_SKIP_JOURNAL_FLUSH = 1 << 0,
COGL_DRAW_SKIP_PIPELINE_VALIDATION = 1 << 1, COGL_DRAW_SKIP_PIPELINE_VALIDATION = 1 << 1,
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH = 1 << 2, COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH = 1 << 2,
/* When flushing from the journal the logged pipeline will already
contain the legacy state overrides so we don't want to apply them
again when we flush the pipeline for drawing */
COGL_DRAW_SKIP_LEGACY_STATE = 1 << 3,
/* By default the vertex attribute drawing code will assume that if /* By default the vertex attribute drawing code will assume that if
there is a color attribute array enabled then we can't determine there is a color attribute array enabled then we can't determine
if the colors will be opaque so we need to enabling if the colors will be opaque so we need to enabling
blending. However when drawing from the journal we know what the blending. However when drawing from the journal we know what the
contents of the color array is so we can override this by passing contents of the color array is so we can override this by passing
this flag. */ this flag. */
COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 3 COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4
} CoglDrawFlags; } CoglDrawFlags;
CoglVertexAttribute * CoglVertexAttribute *

View File

@ -563,7 +563,8 @@ enable_gl_state (CoglDrawFlags flags,
*/ */
} }
if (G_UNLIKELY (ctx->legacy_state_set)) if (G_UNLIKELY (ctx->legacy_state_set) &&
(flags & COGL_DRAW_SKIP_LEGACY_STATE) == 0)
{ {
/* If we haven't already created a derived pipeline... */ /* If we haven't already created a derived pipeline... */
if (!copy) if (!copy)
@ -1033,7 +1034,8 @@ draw_wireframe (CoglVerticesMode mode,
wire_attribute, wire_attribute,
COGL_DRAW_SKIP_JOURNAL_FLUSH | COGL_DRAW_SKIP_JOURNAL_FLUSH |
COGL_DRAW_SKIP_PIPELINE_VALIDATION | COGL_DRAW_SKIP_PIPELINE_VALIDATION |
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
COGL_DRAW_SKIP_LEGACY_STATE);
cogl_debug_flags |= COGL_DEBUG_WIREFRAME; cogl_debug_flags |= COGL_DEBUG_WIREFRAME;