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.
This commit is contained in:
Neil Roberts 2010-11-03 13:34:21 +00:00
parent 6027aa04a4
commit af5ddb0b13

View File

@ -438,14 +438,6 @@ enable_gl_state (CoglVertexAttribute **attributes,
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); _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 (); source = cogl_get_source ();
_cogl_bitmask_clear_all (&ctx->temp_bitmask); _cogl_bitmask_clear_all (&ctx->temp_bitmask);
@ -664,8 +656,9 @@ _cogl_draw_vertex_attributes_array_real (CoglVerticesMode mode,
disable_gl_state (attributes, source); disable_gl_state (attributes, source);
} }
/* This can be used by the CoglJournal to draw attributes skiping /* This can be used by the CoglJournal to draw attributes skipping the
* the implicit journal flush and pipeline validation. */ * implicit journal flush, the framebuffer flush and pipeline
* validation. */
void void
_cogl_draw_vertex_attributes_array (CoglVerticesMode mode, _cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
int first_vertex, int first_vertex,
@ -702,6 +695,14 @@ cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
validate_layer_cb, validate_layer_cb,
&state); &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, _cogl_draw_vertex_attributes_array_real (mode, first_vertex, n_vertices,
attributes, &state); attributes, &state);
} }
@ -838,6 +839,14 @@ cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
validate_layer_cb, validate_layer_cb,
&state); &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, _cogl_draw_indexed_vertex_attributes_array_real (mode,
first_vertex, first_vertex,
n_vertices, n_vertices,