cogl-vertex-attribute: Optionally avoid applying the legacy state
authorNeil Roberts <neil@linux.intel.com>
Mon, 10 Jan 2011 20:13:41 +0000 (20:13 +0000)
committerNeil Roberts <neil@linux.intel.com>
Tue, 11 Jan 2011 14:06:09 +0000 (14:06 +0000)
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.

clutter/cogl/cogl/cogl-journal.c
clutter/cogl/cogl/cogl-vertex-attribute-private.h
clutter/cogl/cogl/cogl-vertex-attribute.c

index 9e6ea22..1ccf1db 100644 (file)
@@ -235,7 +235,8 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
   CoglVertexAttribute **attributes;
   CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH |
                               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,
                      "flush: pipeline+entries", /* parent */
index b3a0e08..a566312 100644 (file)
@@ -62,13 +62,17 @@ typedef enum
   COGL_DRAW_SKIP_JOURNAL_FLUSH = 1 << 0,
   COGL_DRAW_SKIP_PIPELINE_VALIDATION = 1 << 1,
   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
      there is a color attribute array enabled then we can't determine
      if the colors will be opaque so we need to enabling
      blending. However when drawing from the journal we know what the
      contents of the color array is so we can override this by passing
      this flag. */
-  COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 3
+  COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4
 } CoglDrawFlags;
 
 CoglVertexAttribute *
index eb14516..715a176 100644 (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 (!copy)
@@ -1033,7 +1034,8 @@ draw_wireframe (CoglVerticesMode mode,
                                       wire_attribute,
                                       COGL_DRAW_SKIP_JOURNAL_FLUSH |
                                       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;