diff options
author | Ian Romanick <[email protected]> | 2015-05-26 12:07:13 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2015-05-28 16:56:31 -0700 |
commit | 03fd6704db9f1d0f203bf8da18bd587c7e35ce60 (patch) | |
tree | 712a3a279a7e273b15d99f15e9bfffec48a06907 | |
parent | 464c56d3d5ca2c9d6e437e756950f0fa2996d8da (diff) |
mesa: Add support for a new override string MESA_GLES_VERSION_OVERRIDE
The string is only applied when the context is API_OPENGLES2.
The bulk of the change is to prevent overriding the context to
API_OPENGL_CORE based on the requested version. If the context is
API_OPENGL_ES2, don't change it.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
-rw-r--r-- | src/mesa/main/version.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 668658fdbf7..409e5ae3cba 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -51,15 +51,20 @@ check_for_ending(const char *string, const char *ending) * fwd_context is only valid if version > 0 */ static void -get_gl_override(int *version, bool *fwd_context, bool *compat_context) +get_gl_override(gl_api api, int *version, bool *fwd_context, + bool *compat_context) { - const char *env_var = "MESA_GL_VERSION_OVERRIDE"; + const char *env_var = (api == API_OPENGL_CORE || api == API_OPENGL_COMPAT) + ? "MESA_GL_VERSION_OVERRIDE" : "MESA_GLES_VERSION_OVERRIDE"; const char *version_str; int major, minor, n; static int override_version = -1; static bool fc_suffix = false; static bool compat_suffix = false; + if (api == API_OPENGLES) + return; + if (override_version < 0) { override_version = 0; @@ -75,7 +80,12 @@ get_gl_override(int *version, bool *fwd_context, bool *compat_context) override_version = 0; } else { override_version = major * 10 + minor; - if (override_version < 30 && fc_suffix) { + + /* There is no such thing as compatibility or forward-compatible for + * OpenGL ES 2.0 or 3.x APIs. + */ + if ((override_version < 30 && fc_suffix) || + (api == API_OPENGLES2 && (fc_suffix || compat_suffix))) { fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version_str); } @@ -130,18 +140,26 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts, int version; bool fwd_context, compat_context; - get_gl_override(&version, &fwd_context, &compat_context); + get_gl_override(*apiOut, &version, &fwd_context, &compat_context); if (version > 0) { *versionOut = version; - if (version >= 30 && fwd_context) { - *apiOut = API_OPENGL_CORE; - consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; - } else if (version >= 31 && !compat_context) { - *apiOut = API_OPENGL_CORE; - } else { - *apiOut = API_OPENGL_COMPAT; + + /* If the API is a desktop API, adjust the context flags. We may also + * need to modify the API depending on the version. For example, Mesa + * does not support a GL 3.3 compatibility profile. + */ + if (*apiOut == API_OPENGL_CORE || *apiOut == API_OPENGL_COMPAT) { + if (version >= 30 && fwd_context) { + *apiOut = API_OPENGL_CORE; + consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + } else if (version >= 31 && !compat_context) { + *apiOut = API_OPENGL_CORE; + } else { + *apiOut = API_OPENGL_COMPAT; + } } + return true; } return false; |