summaryrefslogtreecommitdiff
path: root/cogl/driver
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-05-11 18:15:25 +0100
committerRobert Bragg <robert@linux.intel.com>2013-08-23 14:51:43 +0100
commit34658ea05787201dd6caaa21fb60c2859fcd765b (patch)
tree364b287fc83abfd6e11fc5a367d9bbcf43a96000 /cogl/driver
parentbd3dce4af1b7b10f85dcf83d3367eb7819c1e287 (diff)
downloadcogl-34658ea05787201dd6caaa21fb60c2859fcd765b.tar.gz
generalize driver description and selection
This adds a table of driver descriptions to cogl-renderer.c in order of preference and when choosing what driver to use we now iterate the table instead of repeating boilerplate checks. For handling the "default driver" that can be specified when building cogl and handling driver overrides there is a foreach_driver_description() that will make sure to iterate the default driver first or if an override has been set then nothing but the override will be considered. This patch introduces some driver flags that let us broadly categorize what kind of GL driver we are currently running on. Since there are numerous OpenGL apis with different broad feature sets and new apis may be introduced in the future by Khronos then we should tend to avoid using the driver id to do runtime feature checking. These flags provide a more stable quantity for broad feature checks. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit e07d0fc7441dddc3f0a2bc33a6a37d62ddc3efc0)
Diffstat (limited to 'cogl/driver')
-rw-r--r--cogl/driver/gl/cogl-attribute-gl.c8
-rw-r--r--cogl/driver/gl/cogl-pipeline-fragend-glsl.c3
-rw-r--r--cogl/driver/gl/cogl-pipeline-opengl.c16
-rw-r--r--cogl/driver/gl/cogl-pipeline-progend-fixed.c2
-rw-r--r--cogl/driver/gl/gl/cogl-driver-gl.c2
-rw-r--r--cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c2
-rw-r--r--cogl/driver/gl/gles/cogl-driver-gles.c2
7 files changed, 17 insertions, 18 deletions
diff --git a/cogl/driver/gl/cogl-attribute-gl.c b/cogl/driver/gl/cogl-attribute-gl.c
index 08354a87..7d1ce237 100644
--- a/cogl/driver/gl/cogl-attribute-gl.c
+++ b/cogl/driver/gl/cogl-attribute-gl.c
@@ -56,7 +56,7 @@ toggle_builtin_attribute_enabled_cb (int bit_num, void *user_data)
CoglContext *context = state->context;
_COGL_RETURN_VAL_IF_FAIL ((context->private_feature_flags &
- COGL_PRIVATE_FEATURE_FIXED_FUNCTION),
+ COGL_PRIVATE_FEATURE_GL_FIXED),
FALSE);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
@@ -93,7 +93,7 @@ toggle_texcood_attribute_enabled_cb (int bit_num, void *user_data)
CoglContext *context = state->context;
_COGL_RETURN_VAL_IF_FAIL ((context->private_feature_flags &
- COGL_PRIVATE_FEATURE_FIXED_FUNCTION),
+ COGL_PRIVATE_FEATURE_GL_FIXED),
FALSE);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
@@ -282,7 +282,7 @@ setup_legacy_buffered_attribute (CoglContext *ctx,
break;
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
#ifdef COGL_PIPELINE_PROGEND_GLSL
- if (ctx->driver != COGL_DRIVER_GLES1)
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE)
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
#endif
break;
@@ -299,7 +299,7 @@ setup_legacy_const_attribute (CoglContext *ctx,
#ifdef COGL_PIPELINE_PROGEND_GLSL
if (attribute->name_state->name_id == COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
{
- if (ctx->driver != COGL_DRIVER_GLES1)
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE)
setup_generic_const_attribute (ctx, pipeline, attribute);
}
else
diff --git a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
index 00e053b4..069a1fee 100644
--- a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
@@ -1054,8 +1054,7 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
source_strings[1] = shader_state->source->str;
if (shader_state->ref_point_coord &&
- (ctx->driver == COGL_DRIVER_GL ||
- ctx->driver == COGL_DRIVER_GL3))
+ !(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_EMBEDDED))
version_string = "#version 120\n";
else
version_string = NULL;
diff --git a/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/driver/gl/cogl-pipeline-opengl.c
index 119b4490..cc3b93c1 100644
--- a/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -434,7 +434,7 @@ flush_depth_state (CoglContext *ctx,
(ctx->depth_range_near_cache != depth_state->range_near ||
ctx->depth_range_far_cache != depth_state->range_far))
{
- if (ctx->driver == COGL_DRIVER_GLES2)
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_EMBEDDED)
GE (ctx, glDepthRangef (depth_state->range_near,
depth_state->range_far));
else
@@ -487,7 +487,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* On GLES2 we'll flush the color later */
- if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION) &&
+ if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED) &&
!with_color_attrib)
{
if ((pipelines_difference & COGL_PIPELINE_STATE_COLOR) ||
@@ -725,8 +725,7 @@ get_max_activateable_texture_units (void)
int i;
#ifdef HAVE_COGL_GL
- if (ctx->driver == COGL_DRIVER_GL ||
- ctx->driver == COGL_DRIVER_GL3)
+ if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_EMBEDDED))
{
/* GL_MAX_TEXTURE_COORDS is provided for both GLSL and ARBfp. It
defines the number of texture coordinates that can be
@@ -749,7 +748,8 @@ get_max_activateable_texture_units (void)
#endif /* HAVE_COGL_GL */
#ifdef HAVE_COGL_GLES2
- if (ctx->driver == COGL_DRIVER_GLES2)
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_EMBEDDED &&
+ ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE)
{
GE (ctx, glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, values + n_values));
/* Two of the vertex attribs need to be used for the position
@@ -761,8 +761,8 @@ get_max_activateable_texture_units (void)
}
#endif
-#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES) /* not GLES2 */
- if (ctx->driver != COGL_DRIVER_GLES2)
+#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED)
{
/* GL_MAX_TEXTURE_UNITS defines the number of units that are
usable from the fixed function pipeline, therefore it isn't
@@ -907,7 +907,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
* glsl progend.
*/
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GL)
- if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION) &&
+ if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED) &&
(layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS))
{
CoglPipelineState change = COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
diff --git a/cogl/driver/gl/cogl-pipeline-progend-fixed.c b/cogl/driver/gl/cogl-pipeline-progend-fixed.c
index 558b5b80..dc2f63db 100644
--- a/cogl/driver/gl/cogl-pipeline-progend-fixed.c
+++ b/cogl/driver/gl/cogl-pipeline-progend-fixed.c
@@ -48,7 +48,7 @@ _cogl_pipeline_progend_fixed_start (CoglPipeline *pipeline)
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
return FALSE;
- if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION))
+ if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED))
return FALSE;
/* Vertex snippets are only supported in the GLSL fragend */
diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index 6705159e..5dc783bb 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -591,7 +591,7 @@ _cogl_driver_update_features (CoglContext *ctx,
int max_clip_planes = 0;
/* Features which are not available in GL 3 */
- private_flags |= (COGL_PRIVATE_FEATURE_FIXED_FUNCTION |
+ private_flags |= (COGL_PRIVATE_FEATURE_GL_FIXED |
COGL_PRIVATE_FEATURE_ALPHA_TEST |
COGL_PRIVATE_FEATURE_QUADS |
COGL_PRIVATE_FEATURE_ALPHA_TEXTURES);
diff --git a/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c b/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
index fe46a0d0..45a9f28a 100644
--- a/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
+++ b/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
@@ -51,7 +51,7 @@ _cogl_pipeline_progend_fixed_arbfp_start (CoglPipeline *pipeline)
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
return FALSE;
- if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION))
+ if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED))
return FALSE;
/* Vertex snippets are only supported in the GLSL fragend */
diff --git a/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/driver/gl/gles/cogl-driver-gles.c
index bdeaa307..ad9f8d1b 100644
--- a/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -262,7 +262,7 @@ _cogl_driver_update_features (CoglContext *context,
private_flags |= COGL_PRIVATE_FEATURE_BLEND_CONSTANT;
}
else if (context->driver == COGL_DRIVER_GLES1)
- private_flags |= (COGL_PRIVATE_FEATURE_FIXED_FUNCTION |
+ private_flags |= (COGL_PRIVATE_FEATURE_GL_FIXED |
COGL_PRIVATE_FEATURE_ALPHA_TEST |
COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM);