mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl-matrix-stack: remove flush avoidance checks
The aim is to make cogl-framebuffer.c responsible for avoiding redundant flushing of its matrix stacks so this removes the checks done directly within cogl-matrix-stack.c. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
ff4921cef9
commit
104a6be84c
@ -1102,16 +1102,6 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
|
|||||||
ctx->dirty_bound_framebuffer = 1;
|
ctx->dirty_bound_framebuffer = 1;
|
||||||
ctx->dirty_gl_viewport = 1;
|
ctx->dirty_gl_viewport = 1;
|
||||||
|
|
||||||
/* We've effectively just switched the current modelview and
|
|
||||||
* projection matrix stacks and clip state so we need to dirty
|
|
||||||
* them to ensure they get flushed for the next batch of geometry
|
|
||||||
* we flush */
|
|
||||||
if (new_draw_buffer)
|
|
||||||
{
|
|
||||||
_cogl_matrix_stack_dirty (new_draw_buffer->modelview_stack);
|
|
||||||
_cogl_matrix_stack_dirty (new_draw_buffer->projection_stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
_cogl_clip_stack_dirty ();
|
_cogl_clip_stack_dirty ();
|
||||||
|
|
||||||
if (old_draw_buffer && new_draw_buffer)
|
if (old_draw_buffer && new_draw_buffer)
|
||||||
|
@ -58,10 +58,6 @@ struct _CoglMatrixStack
|
|||||||
|
|
||||||
GArray *stack;
|
GArray *stack;
|
||||||
|
|
||||||
/* which state does GL have, NULL if unknown */
|
|
||||||
CoglMatrixState *flushed_state;
|
|
||||||
gboolean flushed_identity;
|
|
||||||
|
|
||||||
unsigned int age;
|
unsigned int age;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,9 +120,6 @@ _cogl_matrix_stack_top_mutable (CoglMatrixStack *stack,
|
|||||||
cogl_matrix_init_identity (&new_top->matrix);
|
cogl_matrix_init_identity (&new_top->matrix);
|
||||||
else
|
else
|
||||||
new_top->matrix = state->matrix;
|
new_top->matrix = state->matrix;
|
||||||
|
|
||||||
if (stack->flushed_state == state)
|
|
||||||
stack->flushed_state = new_top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_top;
|
return new_top;
|
||||||
@ -191,11 +184,6 @@ _cogl_matrix_stack_pop (CoglMatrixStack *stack)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack->flushed_state == state)
|
|
||||||
{
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
stack->age++;
|
stack->age++;
|
||||||
g_array_set_size (stack->stack, stack->stack->len - 1);
|
g_array_set_size (stack->stack, stack->stack->len - 1);
|
||||||
}
|
}
|
||||||
@ -218,9 +206,6 @@ _cogl_matrix_stack_load_identity (CoglMatrixStack *stack)
|
|||||||
if (!state->is_identity)
|
if (!state->is_identity)
|
||||||
{
|
{
|
||||||
state->is_identity = TRUE;
|
state->is_identity = TRUE;
|
||||||
|
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,8 +220,6 @@ _cogl_matrix_stack_scale (CoglMatrixStack *stack,
|
|||||||
|
|
||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_scale (&state->matrix, x, y, z);
|
cogl_matrix_scale (&state->matrix, x, y, z);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -251,8 +234,6 @@ _cogl_matrix_stack_translate (CoglMatrixStack *stack,
|
|||||||
|
|
||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_translate (&state->matrix, x, y, z);
|
cogl_matrix_translate (&state->matrix, x, y, z);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -268,8 +249,6 @@ _cogl_matrix_stack_rotate (CoglMatrixStack *stack,
|
|||||||
|
|
||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_rotate (&state->matrix, angle, x, y, z);
|
cogl_matrix_rotate (&state->matrix, angle, x, y, z);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -282,8 +261,6 @@ _cogl_matrix_stack_multiply (CoglMatrixStack *stack,
|
|||||||
|
|
||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_multiply (&state->matrix, &state->matrix, matrix);
|
cogl_matrix_multiply (&state->matrix, &state->matrix, matrix);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -303,8 +280,6 @@ _cogl_matrix_stack_frustum (CoglMatrixStack *stack,
|
|||||||
cogl_matrix_frustum (&state->matrix,
|
cogl_matrix_frustum (&state->matrix,
|
||||||
left, right, bottom, top,
|
left, right, bottom, top,
|
||||||
z_near, z_far);
|
z_near, z_far);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -321,8 +296,6 @@ _cogl_matrix_stack_perspective (CoglMatrixStack *stack,
|
|||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_perspective (&state->matrix,
|
cogl_matrix_perspective (&state->matrix,
|
||||||
fov_y, aspect, z_near, z_far);
|
fov_y, aspect, z_near, z_far);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -341,8 +314,6 @@ _cogl_matrix_stack_ortho (CoglMatrixStack *stack,
|
|||||||
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
state = _cogl_matrix_stack_top_mutable (stack, TRUE);
|
||||||
cogl_matrix_ortho (&state->matrix,
|
cogl_matrix_ortho (&state->matrix,
|
||||||
left, right, bottom, top, z_near, z_far);
|
left, right, bottom, top, z_near, z_far);
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -387,8 +358,6 @@ _cogl_matrix_stack_set (CoglMatrixStack *stack,
|
|||||||
|
|
||||||
state = _cogl_matrix_stack_top_mutable (stack, FALSE);
|
state = _cogl_matrix_stack_top_mutable (stack, FALSE);
|
||||||
state->matrix = *matrix;
|
state->matrix = *matrix;
|
||||||
/* mark dirty */
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
state->is_identity = FALSE;
|
state->is_identity = FALSE;
|
||||||
stack->age++;
|
stack->age++;
|
||||||
}
|
}
|
||||||
@ -401,19 +370,10 @@ flush_to_fixed_api_gl (CoglContext *context,
|
|||||||
const CoglMatrix *matrix,
|
const CoglMatrix *matrix,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
CoglMatrixStack *stack = user_data;
|
|
||||||
|
|
||||||
if (is_identity)
|
if (is_identity)
|
||||||
{
|
GE (context, glLoadIdentity ());
|
||||||
if (!stack->flushed_identity)
|
|
||||||
GE (context, glLoadIdentity ());
|
|
||||||
stack->flushed_identity = TRUE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
GE (context, glLoadMatrixf (cogl_matrix_get_array (matrix)) );
|
||||||
GE (context, glLoadMatrixf (cogl_matrix_get_array (matrix)) );
|
|
||||||
stack->flushed_identity = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -455,8 +415,6 @@ _cogl_matrix_stack_flush_to_gl (CoglContext *context,
|
|||||||
CoglMatrixStack *stack,
|
CoglMatrixStack *stack,
|
||||||
CoglMatrixMode mode)
|
CoglMatrixMode mode)
|
||||||
{
|
{
|
||||||
CoglMatrixState *state = _cogl_matrix_stack_top (stack);
|
|
||||||
|
|
||||||
if (context->driver == COGL_DRIVER_GLES2)
|
if (context->driver == COGL_DRIVER_GLES2)
|
||||||
{
|
{
|
||||||
/* Under GLES2 we need to flush the matrices differently because
|
/* Under GLES2 we need to flush the matrices differently because
|
||||||
@ -493,9 +451,6 @@ _cogl_matrix_stack_flush_to_gl (CoglContext *context,
|
|||||||
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (stack->flushed_state == state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (context->flushed_matrix_mode != mode)
|
if (context->flushed_matrix_mode != mode)
|
||||||
{
|
{
|
||||||
GLenum gl_mode = 0;
|
GLenum gl_mode = 0;
|
||||||
@ -526,15 +481,6 @@ _cogl_matrix_stack_flush_to_gl (CoglContext *context,
|
|||||||
stack);
|
stack);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stack->flushed_state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_cogl_matrix_stack_dirty (CoglMatrixStack *stack)
|
|
||||||
{
|
|
||||||
stack->flushed_state = NULL;
|
|
||||||
stack->flushed_identity = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
@ -111,8 +111,6 @@ void
|
|||||||
_cogl_matrix_stack_flush_to_gl (CoglContext *ctx,
|
_cogl_matrix_stack_flush_to_gl (CoglContext *ctx,
|
||||||
CoglMatrixStack *stack,
|
CoglMatrixStack *stack,
|
||||||
CoglMatrixMode mode);
|
CoglMatrixMode mode);
|
||||||
void
|
|
||||||
_cogl_matrix_stack_dirty (CoglMatrixStack *stack);
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
_cogl_matrix_stack_get_age (CoglMatrixStack *stack);
|
_cogl_matrix_stack_get_age (CoglMatrixStack *stack);
|
||||||
|
Loading…
Reference in New Issue
Block a user