summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-04-01 14:54:38 +0100
committerNeil Roberts <neil@linux.intel.com>2014-06-17 12:07:31 +0100
commit4d892cd97558da61ba526f947ac0555ebab632d2 (patch)
tree9f95cd909ee07459dfe4bfaf9ac8fe4b8fc93d24
parent2eec9758f67e9073371c2edd63379324849373c4 (diff)
downloadcogl-4d892cd97558da61ba526f947ac0555ebab632d2.tar.gz
Add a COGL_EXT_IN_GLES3 option to specify extensions that are in GLES3
Some features that were previously available as an extension in GLES2 are now in core in GLES3 so we should be able to specify that with the gles_availability mask of COGL_EXT_BEGIN so that GL implementations advertising GLES3 don't have to additionally advertise the extension for us to take advantage of it. Reviewed-by: Robert Bragg <robert.bragg@intel.com>
-rw-r--r--cogl/cogl-feature-private.c28
-rw-r--r--cogl/cogl-feature-private.h3
-rw-r--r--cogl/driver/gl/cogl-util-gl-private.h11
-rw-r--r--cogl/driver/gl/cogl-util-gl.c33
-rw-r--r--cogl/driver/gl/gl/cogl-driver-gl.c39
-rw-r--r--cogl/driver/gl/gles/cogl-driver-gles.c30
6 files changed, 102 insertions, 42 deletions
diff --git a/cogl/cogl-feature-private.c b/cogl/cogl-feature-private.c
index 7c75ae23..5b92149e 100644
--- a/cogl/cogl-feature-private.c
+++ b/cogl/cogl-feature-private.c
@@ -53,18 +53,38 @@ _cogl_feature_check (CoglRenderer *renderer,
{
const char *suffix = NULL;
int func_num;
+ CoglExtGlesAvailability gles_availability = 0;
CoglBool in_core;
+ switch (driver)
+ {
+ case COGL_DRIVER_GLES1:
+ gles_availability = COGL_EXT_IN_GLES;
+ break;
+ case COGL_DRIVER_GLES2:
+ gles_availability = COGL_EXT_IN_GLES2;
+
+ if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 3, 0))
+ gles_availability |= COGL_EXT_IN_GLES3;
+ break;
+ case COGL_DRIVER_ANY:
+ g_assert_not_reached ();
+ case COGL_DRIVER_WEBGL:
+ /* FIXME: WebGL should probably have its own COGL_EXT_IN_WEBGL flag */
+ break;
+ case COGL_DRIVER_NOP:
+ case COGL_DRIVER_GL:
+ case COGL_DRIVER_GL3:
+ break;
+ }
+
/* First check whether the functions should be directly provided by
GL */
if (((driver == COGL_DRIVER_GL ||
driver == COGL_DRIVER_GL3) &&
COGL_CHECK_GL_VERSION (gl_major, gl_minor,
data->min_gl_major, data->min_gl_minor)) ||
- (driver == COGL_DRIVER_GLES1 &&
- (data->gles_availability & COGL_EXT_IN_GLES)) ||
- (driver == COGL_DRIVER_GLES2 &&
- (data->gles_availability & COGL_EXT_IN_GLES2)))
+ (data->gles_availability & gles_availability))
{
suffix = "";
in_core = TRUE;
diff --git a/cogl/cogl-feature-private.h b/cogl/cogl-feature-private.h
index 5d8a2733..431bb8d4 100644
--- a/cogl/cogl-feature-private.h
+++ b/cogl/cogl-feature-private.h
@@ -42,7 +42,8 @@
typedef enum
{
COGL_EXT_IN_GLES = (1 << 0),
- COGL_EXT_IN_GLES2 = (1 << 1)
+ COGL_EXT_IN_GLES2 = (1 << 1),
+ COGL_EXT_IN_GLES3 = (1 << 2)
} CoglExtGlesAvailability;
typedef struct _CoglFeatureFunction CoglFeatureFunction;
diff --git a/cogl/driver/gl/cogl-util-gl-private.h b/cogl/driver/gl/cogl-util-gl-private.h
index 2218bcea..4ac72b50 100644
--- a/cogl/driver/gl/cogl-util-gl-private.h
+++ b/cogl/driver/gl/cogl-util-gl-private.h
@@ -79,4 +79,15 @@ _cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
const char **target_string_out,
const char **swizzle_out);
+/* Parses a GL version number stored in a string. @version_string must
+ * point to the beginning of the version number (ie, it can't point to
+ * the "OpenGL ES" part on GLES). The version number can be followed
+ * by the end of the string, a space or a full stop. Anything else
+ * will be treated as invalid. Returns TRUE and sets major_out and
+ * minor_out if it is succesfully parsed or FALSE otherwise. */
+CoglBool
+_cogl_gl_util_parse_gl_version (const char *version_string,
+ int *major_out,
+ int *minor_out);
+
#endif /* _COGL_UTIL_GL_PRIVATE_H_ */
diff --git a/cogl/driver/gl/cogl-util-gl.c b/cogl/driver/gl/cogl-util-gl.c
index cb4d2d20..2cbd2e45 100644
--- a/cogl/driver/gl/cogl-util-gl.c
+++ b/cogl/driver/gl/cogl-util-gl.c
@@ -146,3 +146,36 @@ _cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
if (swizzle_out)
*swizzle_out = tex_coord_swizzle;
}
+
+CoglBool
+_cogl_gl_util_parse_gl_version (const char *version_string,
+ int *major_out,
+ int *minor_out)
+{
+ const char *major_end, *minor_end;
+ int major = 0, minor = 0;
+
+ /* Extract the major number */
+ for (major_end = version_string; *major_end >= '0'
+ && *major_end <= '9'; major_end++)
+ major = (major * 10) + *major_end - '0';
+ /* If there were no digits or the major number isn't followed by a
+ dot then it is invalid */
+ if (major_end == version_string || *major_end != '.')
+ return FALSE;
+
+ /* Extract the minor number */
+ for (minor_end = major_end + 1; *minor_end >= '0'
+ && *minor_end <= '9'; minor_end++)
+ minor = (minor * 10) + *minor_end - '0';
+ /* If there were no digits or there is an unexpected character then
+ it is invalid */
+ if (minor_end == major_end + 1
+ || (*minor_end && *minor_end != ' ' && *minor_end != '.'))
+ return FALSE;
+
+ *major_out = major;
+ *minor_out = minor;
+
+ return TRUE;
+}
diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index 32109c85..f144c786 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -278,39 +278,6 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
}
static CoglBool
-parse_gl_version (const char *version_string,
- int *major_out,
- int *minor_out)
-{
- const char *major_end, *minor_end;
- int major = 0, minor = 0;
-
- /* Extract the major number */
- for (major_end = version_string; *major_end >= '0'
- && *major_end <= '9'; major_end++)
- major = (major * 10) + *major_end - '0';
- /* If there were no digits or the major number isn't followed by a
- dot then it is invalid */
- if (major_end == version_string || *major_end != '.')
- return FALSE;
-
- /* Extract the minor number */
- for (minor_end = major_end + 1; *minor_end >= '0'
- && *minor_end <= '9'; minor_end++)
- minor = (minor * 10) + *minor_end - '0';
- /* If there were no digits or there is an unexpected character then
- it is invalid */
- if (minor_end == major_end + 1
- || (*minor_end && *minor_end != ' ' && *minor_end != '.'))
- return FALSE;
-
- *major_out = major;
- *minor_out = minor;
-
- return TRUE;
-}
-
-static CoglBool
_cogl_get_gl_version (CoglContext *ctx,
int *major_out,
int *minor_out)
@@ -321,7 +288,7 @@ _cogl_get_gl_version (CoglContext *ctx,
if ((version_string = _cogl_context_get_gl_version (ctx)) == NULL)
return FALSE;
- return parse_gl_version (version_string, major_out, minor_out);
+ return _cogl_gl_util_parse_gl_version (version_string, major_out, minor_out);
}
static CoglBool
@@ -431,7 +398,9 @@ _cogl_driver_update_features (CoglContext *ctx,
{
const char *glsl_version =
(char *)ctx->glGetString (GL_SHADING_LANGUAGE_VERSION);
- parse_gl_version (glsl_version, &ctx->glsl_major, &ctx->glsl_minor);
+ _cogl_gl_util_parse_gl_version (glsl_version,
+ &ctx->glsl_major,
+ &ctx->glsl_minor);
}
if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 2))
diff --git a/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/driver/gl/gles/cogl-driver-gles.c
index c8b53f99..3fd3b837 100644
--- a/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -214,12 +214,32 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
}
static CoglBool
+_cogl_get_gl_version (CoglContext *ctx,
+ int *major_out,
+ int *minor_out)
+{
+ const char *version_string;
+
+ /* Get the OpenGL version number */
+ if ((version_string = _cogl_context_get_gl_version (ctx)) == NULL)
+ return FALSE;
+
+ if (!g_str_has_prefix (version_string, "OpenGL ES "))
+ return FALSE;
+
+ return _cogl_gl_util_parse_gl_version (version_string + 10,
+ major_out,
+ minor_out);
+}
+
+static CoglBool
_cogl_driver_update_features (CoglContext *context,
CoglError **error)
{
unsigned long private_features
[COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_N_PRIVATE_FEATURES)] = { 0 };
char **gl_extensions;
+ int gl_major, gl_minor;
int i;
/* We have to special case getting the pointer to the glGetString
@@ -256,9 +276,15 @@ _cogl_driver_update_features (CoglContext *context,
_cogl_gpu_info_init (context, &context->gpu);
+ if (!_cogl_get_gl_version (context, &gl_major, &gl_minor))
+ {
+ gl_major = 1;
+ gl_minor = 1;
+ }
+
_cogl_feature_check_ext_functions (context,
- -1 /* GL major version */,
- -1 /* GL minor version */,
+ gl_major,
+ gl_minor,
gl_extensions);
#ifdef HAVE_COGL_GLES