mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
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
@ -94,16 +94,18 @@ struct _CoglContext
|
||||
CoglMatrix identity_matrix;
|
||||
CoglMatrix y_flip_matrix;
|
||||
|
||||
/* Client-side matrix stack or NULL if none */
|
||||
/* Value that was last used when calling glMatrixMode to avoid
|
||||
calling it multiple times */
|
||||
CoglMatrixMode flushed_matrix_mode;
|
||||
|
||||
/* On GLES2 we need to track the matrices separately because the are
|
||||
stored in GLSL uniforms rather than using the fixed function
|
||||
API. We keep track of the matrix stack that Cogl is trying to
|
||||
flush so we can flush it later after the program is generated. A
|
||||
reference is taken on the stacks. */
|
||||
CoglMatrixStack *flushed_modelview_stack;
|
||||
CoglMatrixStack *flushed_projection_stack;
|
||||
/* The matrix stack that should be used for the next render */
|
||||
CoglMatrixStack *current_projection_stack;
|
||||
CoglMatrixStack *current_modelview_stack;
|
||||
|
||||
/* The last matrix stack with age that was flushed to the GL matrix
|
||||
builtins */
|
||||
CoglMatrixStackCache builtin_flushed_projection;
|
||||
CoglMatrixStackCache builtin_flushed_modelview;
|
||||
|
||||
GArray *texture_units;
|
||||
int active_texture_unit;
|
||||
@ -320,4 +322,12 @@ if (ctxvar == NULL) return retval;
|
||||
|
||||
#define NO_RETVAL
|
||||
|
||||
void
|
||||
_cogl_context_set_current_projection (CoglContext *context,
|
||||
CoglMatrixStack *stack);
|
||||
|
||||
void
|
||||
_cogl_context_set_current_modelview (CoglContext *context,
|
||||
CoglMatrixStack *stack);
|
||||
|
||||
#endif /* __COGL_CONTEXT_PRIVATE_H */
|
||||
|
Reference in New Issue
Block a user