[Cogl] [PATCH 1/3] generalize driver description and selection
Robert Bragg
robert at sixbynine.org
Thu May 30 10:08:26 PDT 2013
From: Robert Bragg <robert at linux.intel.com>
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.
---
cogl/cogl-context.c | 4 +-
cogl/cogl-glsl-shader.c | 2 +-
cogl/cogl-matrix-stack.c | 4 +-
cogl/cogl-private.h | 37 ++-
cogl/cogl-renderer-private.h | 1 +
cogl/cogl-renderer.c | 334 +++++++++++++++------
cogl/cogl-texture-3d.c | 2 +-
cogl/driver/gl/cogl-attribute-gl.c | 8 +-
cogl/driver/gl/cogl-pipeline-fragend-glsl.c | 3 +-
cogl/driver/gl/cogl-pipeline-opengl.c | 16 +-
cogl/driver/gl/cogl-pipeline-progend-fixed.c | 2 +-
cogl/driver/gl/gl/cogl-driver-gl.c | 2 +-
.../gl/gl/cogl-pipeline-progend-fixed-arbfp.c | 2 +-
cogl/driver/gl/gles/cogl-driver-gles.c | 2 +-
14 files changed, 287 insertions(+), 132 deletions(-)
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 41cf52c..ed855cf 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -203,6 +203,8 @@ cogl_context_new (CoglDisplay *display,
context->driver_vtable = display->renderer->driver_vtable;
context->texture_driver = display->renderer->texture_driver;
+ context->private_feature_flags |= display->renderer->private_feature_flags;
+
winsys = _cogl_context_get_winsys (context);
if (!winsys->context_init (context, error))
{
@@ -421,7 +423,7 @@ cogl_context_new (CoglDisplay *display,
pipeline to track whether any layers have point sprite coords
enabled. We don't need to do this for GL3 or GLES2 because point
sprites are handled using a builtin varying in the shader. */
- if ((context->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION) &&
+ if ((context->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED) &&
cogl_has_feature (context, COGL_FEATURE_ID_POINT_SPRITE))
GE (context, glEnable (GL_POINT_SPRITE));
diff --git a/cogl/cogl-glsl-shader.c b/cogl/cogl-glsl-shader.c
index 993ba24..8e50edb 100644
--- a/cogl/cogl-glsl-shader.c
+++ b/cogl/cogl-glsl-shader.c
@@ -65,7 +65,7 @@ _cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx,
lengths[count++] = -1;
}
- if (ctx->driver == COGL_DRIVER_GLES2 &&
+ if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_EMBEDDED &&
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
static const char texture_3d_extension[] =
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index 9bcc4d6..388980d 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -815,7 +815,7 @@ _cogl_matrix_flush_to_gl_builtin (CoglContext *ctx,
CoglMatrix *matrix,
CoglMatrixMode mode)
{
- g_assert ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION));
+ g_assert ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED));
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
if (ctx->flushed_matrix_mode != mode)
@@ -855,7 +855,7 @@ _cogl_matrix_entry_flush_to_gl_builtins (CoglContext *ctx,
CoglFramebuffer *framebuffer,
CoglBool disable_flip)
{
- g_assert ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_FIXED_FUNCTION));
+ g_assert ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED));
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
{
diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h
index 52588db..cc01379 100644
--- a/cogl/cogl-private.h
+++ b/cogl/cogl-private.h
@@ -44,25 +44,30 @@ typedef enum
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888 = 1L<<8,
COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE = 1L<<9,
COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS = 1L<<10,
- COGL_PRIVATE_FEATURE_FIXED_FUNCTION = 1L<<11,
- COGL_PRIVATE_FEATURE_READ_PIXELS_ANY_FORMAT = 1L<<12,
- COGL_PRIVATE_FEATURE_ANY_GL = 1L<<13,
- COGL_PRIVATE_FEATURE_ALPHA_TEST = 1L<<14,
- COGL_PRIVATE_FEATURE_FORMAT_CONVERSION = 1L<<15,
- COGL_PRIVATE_FEATURE_QUADS = 1L<<16,
- COGL_PRIVATE_FEATURE_BLEND_CONSTANT = 1L<<17,
- COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS = 1L<<18,
- COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM = 1L<<19,
- COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS = 1L<<20,
- COGL_PRIVATE_FEATURE_ALPHA_TEXTURES = 1L<<21,
- COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE = 1L<<22,
- COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL = 1L<<23,
- COGL_PRIVATE_FEATURE_ARBFP = 1L<<24,
- COGL_PRIVATE_FEATURE_OES_EGL_SYNC = 1L<<25,
+ COGL_PRIVATE_FEATURE_READ_PIXELS_ANY_FORMAT = 1L<<11,
+ COGL_PRIVATE_FEATURE_ALPHA_TEST = 1L<<12,
+ COGL_PRIVATE_FEATURE_FORMAT_CONVERSION = 1L<<13,
+ COGL_PRIVATE_FEATURE_QUADS = 1L<<14,
+ COGL_PRIVATE_FEATURE_BLEND_CONSTANT = 1L<<15,
+ COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS = 1L<<16,
+ COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM = 1L<<17,
+ COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS = 1L<<18,
+ COGL_PRIVATE_FEATURE_ALPHA_TEXTURES = 1L<<19,
+ COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE = 1L<<20,
+ COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL = 1L<<21,
+ COGL_PRIVATE_FEATURE_ARBFP = 1L<<22,
+ COGL_PRIVATE_FEATURE_OES_EGL_SYNC = 1L<<23,
/* If this is set then the winsys is responsible for queueing dirty
* events. Otherwise a dirty event will be queued when the onscreen
* is first allocated or when it is shown or resized */
- COGL_PRIVATE_FEATURE_DIRTY_EVENTS = 1L<<26
+ COGL_PRIVATE_FEATURE_DIRTY_EVENTS = 1L<<24,
+ /* These features let us avoid conditioning code based on the exact
+ * driver being used and instead check for broad opengl feature
+ * sets that can be shared by several GL apis */
+ COGL_PRIVATE_FEATURE_ANY_GL = 1L<<25,
+ COGL_PRIVATE_FEATURE_GL_FIXED = 1L<<26,
+ COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE = 1L<<27,
+ COGL_PRIVATE_FEATURE_GL_EMBEDDED = 1L<<28
} CoglPrivateFeatureFlags;
/* Sometimes when evaluating pipelines, either during comparisons or
diff --git a/cogl/cogl-renderer-private.h b/cogl/cogl-renderer-private.h
index 62aca7e..bcf0b9a 100644
--- a/cogl/cogl-renderer-private.h
+++ b/cogl/cogl-renderer-private.h
@@ -70,6 +70,7 @@ struct _CoglRenderer
#endif
CoglDriver driver;
+ CoglPrivateFeatureFlags private_feature_flags;
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
GModule *libgl_module;
#endif
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index bfd91cd..c3148eb 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -90,6 +90,83 @@ extern const CoglDriverVtable _cogl_driver_gles;
extern const CoglDriverVtable _cogl_driver_nop;
+typedef struct _CoglDriverDescription
+{
+ CoglDriver id;
+ const char *name;
+ CoglRendererConstraint constraints;
+ CoglPrivateFeatureFlags private_feature_flags;
+ const CoglDriverVtable *vtable;
+ const CoglTextureDriver *texture_driver;
+ const char *libgl_name;
+} CoglDriverDescription;
+
+_COGL_STATIC_ASSERT(sizeof (CoglPrivateFeatureFlags) ==
+ sizeof (unsigned long),
+ "Private feature flags don't fit in long");
+
+static CoglDriverDescription _cogl_drivers[] =
+{
+#ifdef HAVE_COGL_GL
+ {
+ COGL_DRIVER_GL3,
+ "gl3",
+ 0,
+ COGL_PRIVATE_FEATURE_ANY_GL |
+ COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
+ &_cogl_driver_gl,
+ &_cogl_texture_driver_gl,
+ COGL_GL_LIBNAME,
+ },
+ {
+ COGL_DRIVER_GL,
+ "gl",
+ 0,
+ COGL_PRIVATE_FEATURE_ANY_GL |
+ COGL_PRIVATE_FEATURE_GL_FIXED |
+ COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
+ &_cogl_driver_gl,
+ &_cogl_texture_driver_gl,
+ COGL_GL_LIBNAME,
+ },
+#endif
+#ifdef HAVE_COGL_GLES2
+ {
+ COGL_DRIVER_GLES2,
+ "gles2",
+ COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2,
+ COGL_PRIVATE_FEATURE_ANY_GL |
+ COGL_PRIVATE_FEATURE_GL_EMBEDDED |
+ COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
+ &_cogl_driver_gles,
+ &_cogl_texture_driver_gles,
+ COGL_GLES2_LIBNAME,
+ },
+#endif
+#ifdef HAVE_COGL_GLES
+ {
+ COGL_DRIVER_GLES1,
+ "gles1",
+ 0,
+ COGL_PRIVATE_FEATURE_ANY_GL |
+ COGL_PRIVATE_FEATURE_GL_EMBEDDED |
+ COGL_PRIVATE_FEATURE_GL_FIXED,
+ &_cogl_driver_gles,
+ &_cogl_texture_driver_gles,
+ COGL_GLES1_LIBNAME,
+ },
+#endif
+ {
+ COGL_DRIVER_NOP,
+ "nop",
+ 0, /* constraints satisfied */
+ 0, /* flags */
+ &_cogl_driver_nop,
+ NULL, /* texture driver */
+ NULL /* libgl_name */
+ }
+};
+
static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
{
#ifdef COGL_HAS_GLX_SUPPORT
@@ -259,111 +336,206 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
return TRUE;
}
-static CoglBool
-_cogl_renderer_choose_driver (CoglRenderer *renderer,
- CoglError **error)
-{
- const char *driver_name = g_getenv ("COGL_DRIVER");
- const char *libgl_name;
- CoglBool support_gles2_constraint = FALSE;
- GList *l;
+typedef CoglBool (*DriverCallback) (CoglDriverDescription *description,
+ void *user_data);
- if (!driver_name)
- driver_name = _cogl_config_driver;
+static void
+foreach_driver_description (CoglDriver driver_override,
+ DriverCallback callback,
+ void *user_data)
+{
+#ifdef COGL_DEFAULT_DRIVER
+ const CoglDriverDescription *default_driver = NULL;
+#endif
+ int i;
- for (l = renderer->constraints; l; l = l->next)
+ if (driver_override != COGL_DRIVER_ANY)
{
- CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
- if (constraint == COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2)
+ for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
{
- support_gles2_constraint = TRUE;
+ if (_cogl_drivers[i].id == driver_override)
+ {
+ callback (&_cogl_drivers[i], user_data);
+ return;
+ }
+ }
- if (!driver_name && renderer->driver_override == COGL_DRIVER_ANY)
- renderer->driver_override = COGL_DRIVER_GLES2;
+ g_warn_if_reached ();
+ return;
+ }
+
+#ifdef COGL_DEFAULT_DRIVER
+ for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
+ {
+ const CoglDriverDescription *desc = &_cogl_drivers[i];
+ if (g_ascii_strcasecmp (desc->name, COGL_DEFAULT_DRIVER) == 0)
+ {
+ default_driver = desc;
break;
}
}
+ if (default_driver)
+ {
+ if (!callback (default_driver, user_data))
+ return;
+ }
+#endif
+
+ for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
+ {
#ifdef COGL_DEFAULT_DRIVER
- if (!driver_name)
- driver_name = COGL_DEFAULT_DRIVER;
+ if (&_cogl_drivers[i] == default_driver)
+ continue;
#endif
-#ifdef HAVE_COGL_GL
- if (renderer->driver_override == COGL_DRIVER_GL ||
- (renderer->driver_override == COGL_DRIVER_ANY &&
- (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gl"))))
+ if (!callback (&_cogl_drivers[i], user_data))
+ return;
+ }
+}
+
+static CoglDriver
+driver_name_to_id (const char *name)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
{
- renderer->driver = COGL_DRIVER_GL;
- libgl_name = COGL_GL_LIBNAME;
- goto found;
+ if (g_ascii_strcasecmp (_cogl_drivers[i].name, name) == 0)
+ return _cogl_drivers[i].id;
}
- if (renderer->driver_override == COGL_DRIVER_GL3 ||
- (renderer->driver_override == COGL_DRIVER_ANY &&
- (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gl3"))))
+ return COGL_DRIVER_ANY;
+}
+
+static const char *
+driver_id_to_name (CoglDriver id)
+{
+ switch (id)
{
- renderer->driver = COGL_DRIVER_GL3;
- libgl_name = COGL_GL_LIBNAME;
- goto found;
+ case COGL_DRIVER_GL:
+ return "gl";
+ case COGL_DRIVER_GL3:
+ return "gl3";
+ case COGL_DRIVER_GLES1:
+ return "gles1";
+ case COGL_DRIVER_GLES2:
+ return "gles2";
+ case COGL_DRIVER_NOP:
+ return "nop";
+ case COGL_DRIVER_ANY:
+ g_warn_if_reached ();
+ return "any";
}
-#endif
-#ifdef HAVE_COGL_GLES2
- if (renderer->driver_override == COGL_DRIVER_GLES2 ||
- (renderer->driver_override == COGL_DRIVER_ANY &&
- (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles2"))))
+ g_warn_if_reached ();
+ return "unknown";
+}
+
+typedef struct _SatisfyConstraintsState
+{
+ GList *constraints;
+ const CoglDriverDescription *driver_description;
+} SatisfyConstraintsState;
+
+static CoglBool
+satisfy_constraints (CoglDriverDescription *description,
+ void *user_data)
+{
+ SatisfyConstraintsState *state = user_data;
+ GList *l;
+
+ for (l = state->constraints; l; l = l->next)
{
- renderer->driver = COGL_DRIVER_GLES2;
- libgl_name = COGL_GLES2_LIBNAME;
- goto found;
+ CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
+
+ /* If the driver doesn't satisfy any constraint then continue
+ * to the next driver description */
+ if (!(constraint & description->constraints))
+ return TRUE;
}
-#endif
-#ifdef HAVE_COGL_GLES
- if (renderer->driver_override == COGL_DRIVER_GLES1 ||
- (renderer->driver_override == COGL_DRIVER_ANY &&
- (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles1"))))
+ state->driver_description = description;
+
+ return FALSE;
+}
+
+static CoglBool
+_cogl_renderer_choose_driver (CoglRenderer *renderer,
+ CoglError **error)
+{
+ const char *driver_name = g_getenv ("COGL_DRIVER");
+ CoglDriver driver_override = COGL_DRIVER_ANY;
+ const char *invalid_override = NULL;
+ const char *libgl_name;
+ SatisfyConstraintsState state;
+ const CoglDriverDescription *desc;
+
+ if (!driver_name)
+ driver_name = _cogl_config_driver;
+
+ if (driver_name)
{
- renderer->driver = COGL_DRIVER_GLES1;
- libgl_name = COGL_GLES1_LIBNAME;
- goto found;
+ driver_override = driver_name_to_id (driver_name);
+ if (driver_override == COGL_DRIVER_ANY)
+ invalid_override = driver_name;
}
-#endif
+ else
+ driver_override = renderer->driver_override;
- if (renderer->driver_override == COGL_DRIVER_NOP ||
- (renderer->driver_override == COGL_DRIVER_ANY &&
- (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "nop"))))
+ if (driver_override != COGL_DRIVER_ANY)
{
- renderer->driver = COGL_DRIVER_NOP;
- libgl_name = NULL;
- goto found;
+ CoglBool found = FALSE;
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
+ {
+ if (_cogl_drivers[i].id == driver_override)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (!found)
+ invalid_override = driver_id_to_name (driver_override);
}
- _cogl_set_error (error,
- COGL_DRIVER_ERROR,
- COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
- "No suitable driver found");
- return FALSE;
+ if (invalid_override)
+ {
+ _cogl_set_error (error,
+ COGL_RENDERER_ERROR,
+ COGL_RENDERER_ERROR_BAD_CONSTRAINT,
+ "Driver \"%s\" is not available",
+ invalid_override);
+ return FALSE;
+ }
+
+ state.driver_description = NULL;
+ state.constraints = renderer->constraints;
-found:
+ foreach_driver_description (driver_override,
+ satisfy_constraints,
+ &state);
- if (support_gles2_constraint &&
- renderer->driver != COGL_DRIVER_GLES2)
+ if (!state.driver_description)
{
_cogl_set_error (error,
- COGL_RENDERER_ERROR,
- COGL_RENDERER_ERROR_BAD_CONSTRAINT,
- "No suitable driver found");
+ COGL_RENDERER_ERROR,
+ COGL_RENDERER_ERROR_BAD_CONSTRAINT,
+ "No suitable driver found");
return FALSE;
}
+ desc = state.driver_description;
+ renderer->driver = desc->id;
+ renderer->driver_vtable = desc->vtable;
+ renderer->texture_driver = desc->texture_driver;
+ renderer->private_feature_flags = desc->private_feature_flags;
+ libgl_name = desc->libgl_name;
+
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
- if (renderer->driver == COGL_DRIVER_GL ||
- renderer->driver == COGL_DRIVER_GL3 ||
- renderer->driver == COGL_DRIVER_GLES1 ||
- renderer->driver == COGL_DRIVER_GLES2)
+ if (renderer->private_feature_flags & COGL_PRIVATE_FEATURE_ANY_GL)
{
renderer->libgl_module = g_module_open (libgl_name,
G_MODULE_BIND_LAZY);
@@ -380,30 +552,6 @@ found:
#endif /* HAVE_DIRECTLY_LINKED_GL_LIBRARY */
- switch (renderer->driver)
- {
-#ifdef HAVE_COGL_GL
- case COGL_DRIVER_GL:
- case COGL_DRIVER_GL3:
- renderer->driver_vtable = &_cogl_driver_gl;
- renderer->texture_driver = &_cogl_texture_driver_gl;
- break;
-#endif
-
-#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
- case COGL_DRIVER_GLES1:
- case COGL_DRIVER_GLES2:
- renderer->driver_vtable = &_cogl_driver_gles;
- renderer->texture_driver = &_cogl_texture_driver_gles;
- break;
-#endif
-
- case COGL_DRIVER_NOP:
- default:
- renderer->driver_vtable = &_cogl_driver_nop;
- renderer->texture_driver = NULL;
- }
-
return TRUE;
}
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 6453f17..7f29549 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -563,7 +563,7 @@ _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
_cogl_texture_gl_generate_mipmaps (tex);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
- else if (ctx->driver != COGL_DRIVER_GLES2)
+ else if (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_GL_FIXED)
{
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
tex_3d->gl_texture,
diff --git a/cogl/driver/gl/cogl-attribute-gl.c b/cogl/driver/gl/cogl-attribute-gl.c
index dd597d4..cf0fa18 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)
@@ -274,7 +274,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;
@@ -291,7 +291,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 f432a0c..1772a97 100644
--- a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
@@ -1030,8 +1030,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 e4d2976..a3f4e27 100644
--- a/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -432,7 +432,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
@@ -453,7 +453,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) &&
!skip_gl_color)
{
if ((pipelines_difference & COGL_PIPELINE_STATE_COLOR) ||
@@ -654,8 +654,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
@@ -678,7 +677,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
@@ -690,8 +690,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
@@ -836,7 +836,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 5a62a28..c703970 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 9d5f4cd..4008036 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -536,7 +536,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 3d41f92..166cfe9 100644
--- a/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
+++ b/cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
@@ -48,7 +48,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 0438e34..4d92206 100644
--- a/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -250,7 +250,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);
--
1.8.2.1
More information about the Cogl
mailing list