Preserve the CoglDrawFlags when drawing a wireframe

Previously the CoglDrawFlags passed to
_cogl_framebuffer_draw_indexed_attributes when drawing is redirected
to draw a wireframe are overriden to avoid validating the pipeline,
flushing the framebuffer state and flushing the journal. This ends up
breaking scenes that only contain models drawn from attributes in the
application because nothing will flush the matrices. It seems to make
more sense to just use whatever draw flags were passed from the
original draw command so that it will flush the matrices if the caller
was expecting it.

One problem with this is that if the wireframe causes the journal to
be flushed then it will already have temporarily disabled the
wireframe debug flag so the journal will not be drawn with wireframes.
To fix this the patch adds a CoglDrawFlag to disable the wireframe and
uses that instead of disabling the debug flag.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 283f6733e63ba65d9921f45868edaabbd9420a61)
This commit is contained in:
Neil Roberts 2012-05-19 22:47:28 +01:00 committed by Robert Bragg
parent 702873c199
commit 1357c4c6a6
2 changed files with 16 additions and 11 deletions

View File

@ -77,7 +77,10 @@ typedef enum
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 << 4 COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4,
/* This forcibly disables the debug option to divert all drawing to
* wireframes */
COGL_DRAW_SKIP_DEBUG_WIREFRAME = 1 << 5
} CoglDrawFlags; } CoglDrawFlags;
/* During CoglContext initialization we register the "cogl_color_in" /* During CoglContext initialization we register the "cogl_color_in"

View File

@ -3245,7 +3245,8 @@ draw_wireframe (CoglContext *ctx,
int n_vertices, int n_vertices,
CoglAttribute **attributes, CoglAttribute **attributes,
int n_attributes, int n_attributes,
CoglIndices *indices) CoglIndices *indices,
CoglDrawFlags flags)
{ {
CoglIndices *wire_indices; CoglIndices *wire_indices;
CoglPipeline *wire_pipeline; CoglPipeline *wire_pipeline;
@ -3294,7 +3295,7 @@ draw_wireframe (CoglContext *ctx,
} }
/* temporarily disable the wireframe to avoid recursion! */ /* temporarily disable the wireframe to avoid recursion! */
COGL_DEBUG_CLEAR_FLAG (COGL_DEBUG_WIREFRAME); flags |= COGL_DRAW_SKIP_DEBUG_WIREFRAME;
_cogl_framebuffer_draw_indexed_attributes ( _cogl_framebuffer_draw_indexed_attributes (
framebuffer, framebuffer,
wire_pipeline, wire_pipeline,
@ -3304,10 +3305,7 @@ draw_wireframe (CoglContext *ctx,
wire_indices, wire_indices,
attributes, attributes,
n_attributes, n_attributes,
COGL_DRAW_SKIP_JOURNAL_FLUSH | flags);
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
COGL_DRAW_SKIP_LEGACY_STATE);
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME); COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
cogl_object_unref (wire_indices); cogl_object_unref (wire_indices);
@ -3328,11 +3326,13 @@ _cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer,
CoglDrawFlags flags) CoglDrawFlags flags)
{ {
#ifdef COGL_ENABLE_DEBUG #ifdef COGL_ENABLE_DEBUG
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME))) if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME) &&
(flags & COGL_DRAW_SKIP_DEBUG_WIREFRAME) == 0))
draw_wireframe (framebuffer->context, draw_wireframe (framebuffer->context,
framebuffer, pipeline, framebuffer, pipeline,
mode, first_vertex, n_vertices, mode, first_vertex, n_vertices,
attributes, n_attributes, NULL); attributes, n_attributes, NULL,
flags);
else else
#endif #endif
{ {
@ -3422,11 +3422,13 @@ _cogl_framebuffer_draw_indexed_attributes (CoglFramebuffer *framebuffer,
CoglDrawFlags flags) CoglDrawFlags flags)
{ {
#ifdef COGL_ENABLE_DEBUG #ifdef COGL_ENABLE_DEBUG
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME))) if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME) &&
(flags & COGL_DRAW_SKIP_DEBUG_WIREFRAME) == 0))
draw_wireframe (framebuffer->context, draw_wireframe (framebuffer->context,
framebuffer, pipeline, framebuffer, pipeline,
mode, first_vertex, n_vertices, mode, first_vertex, n_vertices,
attributes, n_attributes, indices); attributes, n_attributes, indices,
flags);
else else
#endif #endif
{ {