mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 22:30:12 +01:00
mesa: allow forcing >=3.1 compatibility contexts with MESA_GL_VERSION_OVERRIDE
E.g. the 4.0 compatibility profile can be forced with: MESA_GL_VERSION_OVERRIDE=4.0COMPAT Some tests that I have require 4.0 compatibility. Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
10ffd98c34
commit
2599b92eb9
1 changed files with 10 additions and 6 deletions
|
|
@ -57,13 +57,15 @@ check_for_ending(const char *string, const char *ending)
|
||||||
* fwd_context is only valid if version > 0
|
* fwd_context is only valid if version > 0
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
get_gl_override(int *version, GLboolean *fwd_context)
|
get_gl_override(int *version, GLboolean *fwd_context,
|
||||||
|
GLboolean *compat_context)
|
||||||
{
|
{
|
||||||
const char *env_var = "MESA_GL_VERSION_OVERRIDE";
|
const char *env_var = "MESA_GL_VERSION_OVERRIDE";
|
||||||
const char *version_str;
|
const char *version_str;
|
||||||
int major, minor, n;
|
int major, minor, n;
|
||||||
static int override_version = -1;
|
static int override_version = -1;
|
||||||
static GLboolean fc_suffix = GL_FALSE;
|
static GLboolean fc_suffix = GL_FALSE;
|
||||||
|
static GLboolean compat_suffix = GL_FALSE;
|
||||||
|
|
||||||
if (override_version < 0) {
|
if (override_version < 0) {
|
||||||
override_version = 0;
|
override_version = 0;
|
||||||
|
|
@ -71,6 +73,7 @@ get_gl_override(int *version, GLboolean *fwd_context)
|
||||||
version_str = getenv(env_var);
|
version_str = getenv(env_var);
|
||||||
if (version_str) {
|
if (version_str) {
|
||||||
fc_suffix = check_for_ending(version_str, "FC");
|
fc_suffix = check_for_ending(version_str, "FC");
|
||||||
|
compat_suffix = check_for_ending(version_str, "COMPAT");
|
||||||
|
|
||||||
n = sscanf(version_str, "%u.%u", &major, &minor);
|
n = sscanf(version_str, "%u.%u", &major, &minor);
|
||||||
if (n != 2) {
|
if (n != 2) {
|
||||||
|
|
@ -87,6 +90,7 @@ get_gl_override(int *version, GLboolean *fwd_context)
|
||||||
|
|
||||||
*version = override_version;
|
*version = override_version;
|
||||||
*fwd_context = fc_suffix;
|
*fwd_context = fc_suffix;
|
||||||
|
*compat_context = compat_suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -129,16 +133,16 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts,
|
||||||
gl_api *apiOut, GLuint *versionOut)
|
gl_api *apiOut, GLuint *versionOut)
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
GLboolean fwd_context;
|
GLboolean fwd_context, compat_context;
|
||||||
|
|
||||||
get_gl_override(&version, &fwd_context);
|
get_gl_override(&version, &fwd_context, &compat_context);
|
||||||
|
|
||||||
if (version > 0) {
|
if (version > 0) {
|
||||||
*versionOut = version;
|
*versionOut = version;
|
||||||
if (version >= 30 && fwd_context) {
|
if (version >= 30 && fwd_context) {
|
||||||
*apiOut = API_OPENGL_CORE;
|
*apiOut = API_OPENGL_CORE;
|
||||||
consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
|
consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
|
||||||
} else if (version >= 31) {
|
} else if (version >= 31 && !compat_context) {
|
||||||
*apiOut = API_OPENGL_CORE;
|
*apiOut = API_OPENGL_CORE;
|
||||||
} else {
|
} else {
|
||||||
*apiOut = API_OPENGL_COMPAT;
|
*apiOut = API_OPENGL_COMPAT;
|
||||||
|
|
@ -166,9 +170,9 @@ int
|
||||||
_mesa_get_gl_version_override(void)
|
_mesa_get_gl_version_override(void)
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
GLboolean fwd_context;
|
GLboolean fwd_context, compat_context;
|
||||||
|
|
||||||
get_gl_override(&version, &fwd_context);
|
get_gl_override(&version, &fwd_context, &compat_context);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue