Unify a lot of gles2 vs gl glsl code

Since we used to support hybrid fixed-function + glsl pipelines when
running with OpenGL there were numerous differences in how we handled
codegen and uniform updates between GLES2 and full OpenGL. Now that we
only support end-to-end glsl pipelines this patch can largely unify how
we handle GLES2 and OpenGL.

Most notably we now never use the builtin attribute names. This should
also make it easy for us to support creating strict OpenGL 3.1 contexts
where the builtin names have been removed.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2701b93f159bf2d3387cedf2d06fe921ad5641f3)
This commit is contained in:
Robert Bragg
2012-09-23 13:32:36 +01:00
parent 62b472f4f5
commit 01937201e4
11 changed files with 233 additions and 341 deletions

View File

@ -850,8 +850,11 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
GE( ctx, glBindSampler (unit_index, sampler_state->sampler_object) );
}
/* Under GLES2 the fragment shader will use gl_PointCoord instead of
replacing the texture coordinates */
/* FIXME: If using GLSL the progend we will use gl_PointCoord
* instead of us needing to replace the texture coordinates but at
* this point we can't currently tell if we are using the fixed or
* glsl progend.
*/
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GL)
if (ctx->driver != COGL_DRIVER_GLES2 &&
(layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS))
@ -1342,12 +1345,11 @@ done:
progend = _cogl_pipeline_progends[pipeline->progend];
/* We can't assume the color will be retained between flushes on
GLES2 because the generic attribute values are not stored as part
of the program object so they could be overridden by any
attribute changes in another program */
#ifdef HAVE_COGL_GLES2
if (ctx->driver == COGL_DRIVER_GLES2 && !skip_gl_color)
/* We can't assume the color will be retained between flushes when
* using the glsl progend because the generic attribute values are
* not stored as part of the program object so they could be
* overridden by any attribute changes in another program */
if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL && !skip_gl_color)
{
int attribute;
CoglPipeline *authority =
@ -1364,7 +1366,6 @@ done:
cogl_color_get_blue_float (&authority->color),
cogl_color_get_alpha_float (&authority->color)));
}
#endif
/* Give the progend a chance to update any uniforms that might not
* depend on the material state. This is used on GLES2 to update the