[cogl/wip/neil/snippets: 25/26] glsl: Use a constant vector for flipping when all fbs flip
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/snippets: 25/26] glsl: Use a constant vector for flipping when all fbs flip
- Date: Fri, 2 Dec 2011 12:47:07 +0000 (UTC)
commit 221fca7b1584f658ae29cc806dae7e2db3eb3161
Author: Neil Roberts <neil linux intel com>
Date: Thu Dec 1 15:08:22 2011 +0000
glsl: Use a constant vector for flipping when all fbs flip
When the backend flips for both types of framebuffer or neither type
of framebuffer the vertend now hardcodes the vector for the flip
instead of adding the uniform. This is expected to happen for the KMS
backend so we might as well use this as a small optimisation.
cogl/cogl-pipeline-progend-glsl.c | 9 ++++++---
cogl/cogl-pipeline-vertend-glsl.c | 20 ++++++++++++++++----
2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index 7cc9a09..9397e80 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -142,6 +142,7 @@ typedef struct
the framebuffer requires it only when there are vertex
snippets. Otherwise this is acheived using the projection
matrix */
+ gboolean has_vertex_snippets;
GLint flip_uniform;
int flushed_flip_state;
@@ -797,6 +798,8 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
GE_RET (program_state->flip_uniform,
ctx, glGetUniformLocation (gl_program, "_cogl_flip_vector"));
program_state->flushed_flip_state = -1;
+ program_state->has_vertex_snippets =
+ _cogl_pipeline_has_vertex_snippets (pipeline);
}
state.unit = 0;
@@ -999,7 +1002,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline)
check_and_update_matrix_cache (projection_stack,
&program_state->projection_cache,
needs_flip &&
- program_state->flip_uniform == -1);
+ !program_state->has_vertex_snippets);
modelview_changed =
check_and_update_matrix_cache (modelview_stack,
@@ -1022,7 +1025,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline)
_cogl_matrix_stack_get (modelview_stack, &modelview);
if (need_projection)
{
- if (needs_flip && program_state->flip_uniform == -1)
+ if (needs_flip && !program_state->has_vertex_snippets)
{
CoglMatrix tmp_matrix;
_cogl_matrix_stack_get (projection_stack, &tmp_matrix);
@@ -1082,7 +1085,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline)
/* If there are vertex snippets, then we'll disable flipping the
geometry via the matrix and use the flip vertex instead */
- disable_flip = program_state->flip_uniform != -1;
+ disable_flip = program_state->has_vertex_snippets;
_cogl_matrix_stack_flush_to_gl_builtins (ctx,
projection_stack,
diff --git a/cogl/cogl-pipeline-vertend-glsl.c b/cogl/cogl-pipeline-vertend-glsl.c
index 602cf02..c116728 100644
--- a/cogl/cogl-pipeline-vertend-glsl.c
+++ b/cogl/cogl-pipeline-vertend-glsl.c
@@ -469,10 +469,22 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline,
uniform */
if (_cogl_pipeline_has_vertex_snippets (pipeline))
{
- g_string_append (shader_state->header,
- "uniform vec4 _cogl_flip_vector;\n");
- g_string_append (shader_state->source,
- " cogl_position_out *= _cogl_flip_vector;\n");
+ /* If the backend always needs flipping then we might as
+ well hardcode the flip instead of using a uniform */
+ if (ctx->framebuffer_orientation ==
+ (COGL_RENDERER_FLIP_ONSCREEN | COGL_RENDERER_FLIP_OFFSCREEN))
+ {
+ g_string_append (shader_state->source,
+ " cogl_position_out *= "
+ "vec4 (1.0, -1.0, 1.0, 1.0);\n");
+ }
+ else if (ctx->framebuffer_orientation != 0)
+ {
+ g_string_append (shader_state->header,
+ "uniform vec4 _cogl_flip_vector;\n");
+ g_string_append (shader_state->source,
+ " cogl_position_out *= _cogl_flip_vector;\n");
+ }
}
g_string_append (shader_state->source,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]