summaryrefslogtreecommitdiff
path: root/cogl/cogl-clip-stack.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-11-29 14:21:07 +0000
committerRobert Bragg <robert@linux.intel.com>2011-12-06 19:02:06 +0000
commitf005f517fe03f28bb7fe09383490d069fc1400e9 (patch)
tree5d65e12140a474d5d541487f9ee1a8e9b8881ff6 /cogl/cogl-clip-stack.c
parent7590fc3ec35aa87f980ebed4fef634b50fcd2460 (diff)
downloadcogl-f005f517fe03f28bb7fe09383490d069fc1400e9.tar.gz
Flush matrices in the progend and flip with a vector
Previously flushing the matrices was performed as part of the framebuffer state. When on GLES2 this matrix flushing is actually diverted so that it only keeps a reference to the intended matrix stack. This is necessary because on GLES2 there are no builtin uniforms so it can't actually flush the matrices until the program for the pipeline is generated. When the matrices are flushed it would store the age of modifications on the matrix stack so that it could detect when the matrix hasn't changed and avoid flushing it. This patch changes it so that the pipeline is responsible for flushing the matrices even when we are using the GL builtins. The same mechanism for detecting unmodified matrix stacks is used in all cases. There is a new CoglMatrixStackCache type which is used to store a reference to the intended matrix stack along with its last flushed age. There are now two of these attached to the CoglContext to track the flushed state for the global matrix builtins and also two for each glsl progend program state to track the flushed state for a program. The framebuffer matrix flush now just updates the intended matrix stacks without actually trying to flush. When a vertex snippet is attached to the pipeline, the GLSL vertend will now avoid using the projection matrix to flip the rendering. This is necessary because any vertex snippet may cause the projection matrix not to be used. Instead the flip is done as a forced final step by multiplying cogl_position_out by a vec4 uniform. This uniform is updated as part of the progend pre_paint depending on whether the framebuffer is offscreen or not. Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'cogl/cogl-clip-stack.c')
-rw-r--r--cogl/cogl-clip-stack.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/cogl/cogl-clip-stack.c b/cogl/cogl-clip-stack.c
index 8600f301..5cc49817 100644
--- a/cogl/cogl-clip-stack.c
+++ b/cogl/cogl-clip-stack.c
@@ -109,7 +109,13 @@ set_clip_plane (CoglFramebuffer *framebuffer,
_cogl_matrix_stack_translate (modelview_stack,
-vertex_a[0], -vertex_a[1], -vertex_a[2]);
- _cogl_matrix_stack_flush_to_gl (ctx, modelview_stack, COGL_MATRIX_MODELVIEW);
+ /* Clip planes can only be used when a fixed function backend is in
+ use so we know we can directly push this matrix to the builtin
+ state */
+ _cogl_matrix_stack_flush_to_gl_builtins (ctx,
+ modelview_stack,
+ COGL_MATRIX_MODELVIEW,
+ FALSE /* don't disable flip */);
planef[0] = 0;
planef[1] = -1.0;
@@ -218,12 +224,8 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
/* This can be called from the journal code which doesn't flush
the matrix stacks between calls so we need to ensure they're
flushed now */
- _cogl_matrix_stack_flush_to_gl (ctx,
- modelview_stack,
- COGL_MATRIX_MODELVIEW);
- _cogl_matrix_stack_flush_to_gl (ctx,
- projection_stack,
- COGL_MATRIX_PROJECTION);
+ _cogl_context_set_current_projection (ctx, projection_stack);
+ _cogl_context_set_current_modelview (ctx, modelview_stack);
if (first)
{
@@ -258,12 +260,8 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
_cogl_matrix_stack_push (modelview_stack);
_cogl_matrix_stack_load_identity (modelview_stack);
- _cogl_matrix_stack_flush_to_gl (ctx,
- modelview_stack,
- COGL_MATRIX_MODELVIEW);
- _cogl_matrix_stack_flush_to_gl (ctx,
- projection_stack,
- COGL_MATRIX_PROJECTION);
+ _cogl_context_set_current_projection (ctx, projection_stack);
+ _cogl_context_set_current_modelview (ctx, modelview_stack);
_cogl_rectangle_immediate (-1.0, -1.0, 1.0, 1.0);
@@ -301,12 +299,8 @@ add_stencil_clip_silhouette (CoglFramebuffer *framebuffer,
/* This can be called from the clip stack code which doesn't flush
the matrix stacks between calls so we need to ensure they're
flushed now */
- _cogl_matrix_stack_flush_to_gl (ctx,
- modelview_stack,
- COGL_MATRIX_MODELVIEW);
- _cogl_matrix_stack_flush_to_gl (ctx,
- projection_stack,
- COGL_MATRIX_PROJECTION);
+ _cogl_context_set_current_projection (ctx, projection_stack);
+ _cogl_context_set_current_modelview (ctx, modelview_stack);
/* Just setup a simple pipeline that doesn't use texturing... */
_cogl_push_source (ctx->stencil_pipeline, FALSE);
@@ -366,15 +360,9 @@ add_stencil_clip_silhouette (CoglFramebuffer *framebuffer,
_cogl_matrix_stack_push (projection_stack);
_cogl_matrix_stack_load_identity (projection_stack);
- _cogl_matrix_stack_flush_to_gl (ctx,
- projection_stack,
- COGL_MATRIX_PROJECTION);
_cogl_matrix_stack_push (modelview_stack);
_cogl_matrix_stack_load_identity (modelview_stack);
- _cogl_matrix_stack_flush_to_gl (ctx,
- modelview_stack,
- COGL_MATRIX_MODELVIEW);
_cogl_rectangle_immediate (-1.0, -1.0, 1.0, 1.0);
_cogl_rectangle_immediate (-1.0, -1.0, 1.0, 1.0);