From af5ddb0b132c4088285f6ebbcb3e9b17cca0d6b7 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 3 Nov 2010 13:34:21 +0000 Subject: [PATCH] cogl: Don't flush the framebuffer state for the internal draw CoglVertexAttribute has an internal draw function that is used by the CoglJournal to avoid the call to cogl_journal_flush which would otherwise end up recursively flushing the journal forever. The enable_gl_state function called by this was previously also calling _cogl_flush_framebuffer_state. However the journal code tries to handle this function specially by calling it with a flag to disable flushing the modelview matrix. This is useful because the journal handles flushing the modelview itself. Without this patch the journal state ends up getting flushed twice. This isn't a particularly big problem currently because the matrix stack has caching to recognise when it would push the same state twice and bails out. However if we later want to use the framebuffer flush flags to override a particular state of the framebuffer (such as the clip state) then we need to make sure the flush isn't called twice. --- cogl/cogl-vertex-attribute.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/cogl/cogl-vertex-attribute.c b/cogl/cogl-vertex-attribute.c index 2a6d5e116..8c1995d28 100644 --- a/cogl/cogl-vertex-attribute.c +++ b/cogl/cogl-vertex-attribute.c @@ -438,14 +438,6 @@ enable_gl_state (CoglVertexAttribute **attributes, _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the pipeline state) when flushing the clip stack, so should - * always be done first when preparing to draw. We need to do this - * before setting up the array pointers because setting up the clip - * stack can cause some drawing which would change the array - * pointers. */ - _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); - source = cogl_get_source (); _cogl_bitmask_clear_all (&ctx->temp_bitmask); @@ -664,8 +656,9 @@ _cogl_draw_vertex_attributes_array_real (CoglVerticesMode mode, disable_gl_state (attributes, source); } -/* This can be used by the CoglJournal to draw attributes skiping - * the implicit journal flush and pipeline validation. */ +/* This can be used by the CoglJournal to draw attributes skipping the + * implicit journal flush, the framebuffer flush and pipeline + * validation. */ void _cogl_draw_vertex_attributes_array (CoglVerticesMode mode, int first_vertex, @@ -702,6 +695,14 @@ cogl_draw_vertex_attributes_array (CoglVerticesMode mode, validate_layer_cb, &state); + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such + * as the pipeline state) when flushing the clip stack, so should + * always be done first when preparing to draw. We need to do this + * before setting up the array pointers because setting up the clip + * stack can cause some drawing which would change the array + * pointers. */ + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); + _cogl_draw_vertex_attributes_array_real (mode, first_vertex, n_vertices, attributes, &state); } @@ -838,6 +839,14 @@ cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, validate_layer_cb, &state); + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such + * as the pipeline state) when flushing the clip stack, so should + * always be done first when preparing to draw. We need to do this + * before setting up the array pointers because setting up the clip + * stack can cause some drawing which would change the array + * pointers. */ + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); + _cogl_draw_indexed_vertex_attributes_array_real (mode, first_vertex, n_vertices,