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>
This commit is contained in:

committed by
Robert Bragg

parent
7590fc3ec3
commit
f005f517fe
@ -1382,20 +1382,20 @@ static unsigned long
|
||||
_cogl_framebuffer_compare_modelview_state (CoglFramebuffer *a,
|
||||
CoglFramebuffer *b)
|
||||
{
|
||||
if (!_cogl_matrix_stack_equal (a->modelview_stack, b->modelview_stack))
|
||||
return COGL_FRAMEBUFFER_STATE_MODELVIEW;
|
||||
else
|
||||
return 0;
|
||||
/* We always want to flush the modelview state. All this does is set
|
||||
the current modelview stack on the context to the framebuffer's
|
||||
stack. */
|
||||
return COGL_FRAMEBUFFER_STATE_MODELVIEW;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
_cogl_framebuffer_compare_projection_state (CoglFramebuffer *a,
|
||||
CoglFramebuffer *b)
|
||||
{
|
||||
if (!_cogl_matrix_stack_equal (a->projection_stack, b->projection_stack))
|
||||
return COGL_FRAMEBUFFER_STATE_MODELVIEW;
|
||||
else
|
||||
return 0;
|
||||
/* We always want to flush the projection state. All this does is
|
||||
set the current projection stack on the context to the
|
||||
framebuffer's stack. */
|
||||
return COGL_FRAMEBUFFER_STATE_PROJECTION;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
@ -1533,17 +1533,15 @@ _cogl_framebuffer_flush_dither_state (CoglFramebuffer *framebuffer)
|
||||
static void
|
||||
_cogl_framebuffer_flush_modelview_state (CoglFramebuffer *framebuffer)
|
||||
{
|
||||
_cogl_matrix_stack_flush_to_gl (framebuffer->context,
|
||||
framebuffer->modelview_stack,
|
||||
COGL_MATRIX_MODELVIEW);
|
||||
_cogl_context_set_current_modelview (framebuffer->context,
|
||||
framebuffer->modelview_stack);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_framebuffer_flush_projection_state (CoglFramebuffer *framebuffer)
|
||||
{
|
||||
_cogl_matrix_stack_flush_to_gl (framebuffer->context,
|
||||
framebuffer->projection_stack,
|
||||
COGL_MATRIX_PROJECTION);
|
||||
_cogl_context_set_current_projection (framebuffer->context,
|
||||
framebuffer->projection_stack);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user