Don't use cogl_get_draw_framebuffer when flushing pipeline state

Some of the state when flushing a pipeline depends on the current
framebuffer being used. These are:

• The matrix stack, so that it can flip vertically or not depending on
  whether the framebuffer is offscreen.
• The colormask. This is combined with the framebuffer's color mask.
• The cull face mode. If the framebuffer is offscreen then backface
  culling is translated to frontface culling and vice-versa.

These states were not working if the new framebuffer draw_primitive
API was used because in that case the framebuffer is not pushed to the
framebuffer stack so it would use the wrong one. This patch changes it
to use ctx->current_draw_buffer which is a pointer to the framebuffer
whose state was last flushed.

https://bugzilla.gnome.org/show_bug.cgi?id=670793

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2012-02-25 15:10:02 +00:00
parent 6ad168e4be
commit 75226501cf
3 changed files with 5 additions and 7 deletions

View File

@ -430,7 +430,7 @@ _cogl_matrix_stack_flush_to_gl_builtins (CoglContext *ctx,
if (disable_flip)
needs_flip = FALSE;
else
needs_flip = cogl_is_offscreen (cogl_get_draw_framebuffer ());
needs_flip = cogl_is_offscreen (ctx->current_draw_buffer);
cache = &ctx->builtin_flushed_projection;
}

View File

@ -593,10 +593,9 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS);
CoglPipelineLogicOpsState *logic_ops_state = &authority->big_state->logic_ops_state;
CoglColorMask color_mask = logic_ops_state->color_mask;
CoglFramebuffer *draw_framebuffer = cogl_get_draw_framebuffer ();
if (draw_framebuffer)
color_mask &= draw_framebuffer->color_mask;
if (ctx->current_draw_buffer)
color_mask &= ctx->current_draw_buffer->color_mask;
GE (ctx, glColorMask (!!(color_mask & COGL_COLOR_MASK_RED),
!!(color_mask & COGL_COLOR_MASK_GREEN),
@ -616,7 +615,6 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
GE( ctx, glDisable (GL_CULL_FACE) );
else
{
CoglFramebuffer *draw_framebuffer = cogl_get_draw_framebuffer ();
gboolean invert_winding;
GE( ctx, glEnable (GL_CULL_FACE) );
@ -642,7 +640,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
/* If we are painting to an offscreen framebuffer then we
need to invert the winding of the front face because
everything is painted upside down */
invert_winding = cogl_is_offscreen (draw_framebuffer);
invert_winding = cogl_is_offscreen (ctx->current_draw_buffer);
switch (cull_face_state->front_winding)
{

View File

@ -951,7 +951,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline)
if (modelview_stack == NULL || projection_stack == NULL)
return;
needs_flip = cogl_is_offscreen (cogl_get_draw_framebuffer ());
needs_flip = cogl_is_offscreen (ctx->current_draw_buffer);
#ifdef HAVE_COGL_GLES2
if (ctx->driver == COGL_DRIVER_GLES2)