summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-03-13 16:07:33 +0000
committerJose Fonseca <jfonseca@vmware.com>2015-03-13 16:07:33 +0000
commit56c419c55aef7105bf4991a2b9265c21614d443a (patch)
tree084522d02ff1c0e2e9b20061b1b75aa66dbd37ed
parentcc41a48baff8d13bcd10cd96879ffdcf29beb1f2 (diff)
glretrace: Set FORWARD_COMPATIBLE_BIT as per trace.
Not thoroughly tested across all platforms. But hopefully close enough.
-rw-r--r--helpers/glprofile.cpp31
-rw-r--r--helpers/glprofile.hpp19
-rw-r--r--retrace/glretrace_egl.cpp4
-rw-r--r--retrace/glretrace_ws.cpp8
-rw-r--r--retrace/glws_egl_xlib.cpp12
-rw-r--r--retrace/glws_glx.cpp9
-rw-r--r--retrace/glws_waffle.cpp3
-rw-r--r--retrace/glws_wgl.cpp9
8 files changed, 77 insertions, 18 deletions
diff --git a/helpers/glprofile.cpp b/helpers/glprofile.cpp
index 6207094e..de996b33 100644
--- a/helpers/glprofile.cpp
+++ b/helpers/glprofile.cpp
@@ -42,9 +42,13 @@ operator << (std::ostream &os, const Profile & profile) {
os << " ES";
}
os << " " << profile.major << "." << profile.minor;
- if (profile.api == API_GL &&
- profile.versionGreaterOrEqual(3, 2)) {
- os << " " << (profile.core ? "core" : "compat");
+ if (profile.api == API_GL) {
+ if (profile.versionGreaterOrEqual(3, 2)) {
+ os << " " << (profile.core ? "core" : "compat");
+ }
+ if (profile.forwardCompatible) {
+ os << " forward-compatible";
+ }
}
return os;
}
@@ -194,12 +198,21 @@ getCurrentContextProfile(void)
}
}
- if (profile.api == API_GL &&
- profile.versionGreaterOrEqual(3, 2)) {
- GLint profileMask = 0;
- _glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask);
- if (profileMask & GL_CONTEXT_CORE_PROFILE_BIT) {
- profile.core = true;
+ if (profile.api == API_GL) {
+ if (profile.versionGreaterOrEqual(3, 0)) {
+ GLint contextFlags = 0;
+ _glGetIntegerv(GL_CONTEXT_FLAGS, &contextFlags);
+ if (contextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) {
+ profile.forwardCompatible = true;
+ }
+ }
+
+ if (profile.versionGreaterOrEqual(3, 2)) {
+ GLint profileMask = 0;
+ _glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask);
+ if (profileMask & GL_CONTEXT_CORE_PROFILE_BIT) {
+ profile.core = true;
+ }
}
}
diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp
index cf2947bd..f6ecf578 100644
--- a/helpers/glprofile.hpp
+++ b/helpers/glprofile.hpp
@@ -52,13 +52,21 @@ struct Profile {
unsigned minor:8;
unsigned api:1;
unsigned core:1;
+ unsigned forwardCompatible:1;
inline
- Profile(Api _api = API_GL, unsigned _major = 1, unsigned _minor = 0, bool _core = false) {
+ Profile(
+ Api _api = API_GL,
+ unsigned _major = 1,
+ unsigned _minor = 0,
+ bool _core = false,
+ bool _forwardCompatible = false
+ ) {
api = _api;
major = _major;
minor = _minor;
core = _core;
+ forwardCompatible = _forwardCompatible;
}
inline bool
@@ -93,7 +101,8 @@ struct Profile {
return api == expected.api &&
versionGreaterOrEqual(expected.major, expected.minor) &&
(core == expected.core ||
- (expected.major == 3 && expected.minor == 1));
+ (expected.major == 3 && expected.minor == 1)) &&
+ forwardCompatible <= expected.forwardCompatible;
}
// Comparison operator, mainly for use in std::map
@@ -102,7 +111,8 @@ struct Profile {
return major == other.major &&
minor == other.minor &&
api == other.api &&
- core == other.core;
+ core == other.core &&
+ forwardCompatible == other.forwardCompatible;
}
// Comparison operator, mainly for use in std::map
@@ -111,7 +121,8 @@ struct Profile {
return major < other.major ||
minor < other.minor ||
api < other.api ||
- core < other.core;
+ core < other.core ||
+ forwardCompatible < other.forwardCompatible;
}
};
diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp
index 13a7d33b..3833f894 100644
--- a/retrace/glretrace_egl.cpp
+++ b/retrace/glretrace_egl.cpp
@@ -172,6 +172,10 @@ static void retrace_eglCreateContext(trace::Call &call) {
if (profileMask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR) {
profile.core = true;
}
+ int contextFlags = parseAttrib(attrib_array, EGL_CONTEXT_FLAGS_KHR, 0);
+ if (contextFlags & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) {
+ profile.forwardCompatible = true;
+ }
}
break;
case EGL_OPENGL_ES_API:
diff --git a/retrace/glretrace_ws.cpp b/retrace/glretrace_ws.cpp
index bd36382a..d007e270 100644
--- a/retrace/glretrace_ws.cpp
+++ b/retrace/glretrace_ws.cpp
@@ -289,6 +289,13 @@ parseContextAttribList(const trace::Value *attribs)
core_profile = false;
}
+ int context_flags = parseAttrib(attribs, GL_CONTEXT_FLAGS, 0);
+
+ bool forward_compatible = context_flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+ if (major_version < 3) {
+ forward_compatible = false;
+ }
+
// {GLX,WGL}_CONTEXT_ES_PROFILE_BIT_EXT
bool es_profile = profile_mask & 0x0004;
@@ -298,6 +305,7 @@ parseContextAttribList(const trace::Value *attribs)
} else {
profile.api = glprofile::API_GL;
profile.core = core_profile;
+ profile.forwardCompatible = forward_compatible;
}
profile.major = major_version;
diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp
index 81058d64..06fa0041 100644
--- a/retrace/glws_egl_xlib.cpp
+++ b/retrace/glws_egl_xlib.cpp
@@ -396,6 +396,7 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
share_context = static_cast<EglContext*>(shareContext)->context;
}
+ int contextFlags = 0;
if (profile.api == glprofile::API_GL) {
load("libGL.so.1");
@@ -404,6 +405,9 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
attribs.add(EGL_CONTEXT_MINOR_VERSION_KHR, profile.minor);
int profileMask = profile.core ? EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR : EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
attribs.add(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, profileMask);
+ if (profile.forwardCompatible) {
+ contextFlags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+ }
} else if (profile.versionGreaterOrEqual(3, 2)) {
std::cerr << "error: EGL_KHR_create_context not supported\n";
return NULL;
@@ -426,10 +430,12 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
return NULL;
}
- if (debug && has_EGL_KHR_create_context) {
- attribs.add(EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR);
+ if (debug) {
+ contextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+ }
+ if (contextFlags && has_EGL_KHR_create_context) {
+ attribs.add(EGL_CONTEXT_FLAGS_KHR, contextFlags);
}
-
attribs.end(EGL_NONE);
EGLenum api = translateAPI(profile);
diff --git a/retrace/glws_glx.cpp b/retrace/glws_glx.cpp
index c3250ab4..9970ae95 100644
--- a/retrace/glws_glx.cpp
+++ b/retrace/glws_glx.cpp
@@ -285,6 +285,7 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
Attributes<int> attribs;
attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
+ int contextFlags = 0;
if (profile.api == glprofile::API_GL) {
attribs.add(GLX_CONTEXT_MAJOR_VERSION_ARB, profile.major);
attribs.add(GLX_CONTEXT_MINOR_VERSION_ARB, profile.minor);
@@ -295,6 +296,9 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
}
int profileMask = profile.core ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
attribs.add(GLX_CONTEXT_PROFILE_MASK_ARB, profileMask);
+ if (profile.forwardCompatible) {
+ contextFlags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ }
}
} else if (profile.api == glprofile::API_GLES) {
if (has_GLX_EXT_create_context_es_profile) {
@@ -315,7 +319,10 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
assert(0);
}
if (debug) {
- attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
+ contextFlags |= GLX_CONTEXT_DEBUG_BIT_ARB;
+ }
+ if (contextFlags) {
+ attribs.add(GLX_CONTEXT_FLAGS_ARB, contextFlags);
}
attribs.end();
diff --git a/retrace/glws_waffle.cpp b/retrace/glws_waffle.cpp
index 92eabaf7..4cb3b45a 100644
--- a/retrace/glws_waffle.cpp
+++ b/retrace/glws_waffle.cpp
@@ -169,6 +169,9 @@ createVisual(bool doubleBuffer, unsigned samples, Profile profile) {
int profileMask = profile.core ? WAFFLE_CONTEXT_CORE_PROFILE : WAFFLE_CONTEXT_COMPATIBILITY_PROFILE;
config_attrib_list.add(WAFFLE_CONTEXT_PROFILE, profileMask);
}
+ if (profile.forwardCompatible) {
+ config_attrib_list.add(WAFFLE_CONTEXT_FORWARD_COMPATIBLE, true);
+ }
}
config_attrib_list.add(WAFFLE_RED_SIZE, 8);
config_attrib_list.add(WAFFLE_GREEN_SIZE, 8);
diff --git a/retrace/glws_wgl.cpp b/retrace/glws_wgl.cpp
index 63d02f7b..6db86d5f 100644
--- a/retrace/glws_wgl.cpp
+++ b/retrace/glws_wgl.cpp
@@ -372,6 +372,7 @@ public:
wglMakeCurrent(hDC, NULL);
Attributes<int> attribs;
+ int contextFlags = 0;
if (profile.api == glprofile::API_GL) {
attribs.add(WGL_CONTEXT_MAJOR_VERSION_ARB, profile.major);
attribs.add(WGL_CONTEXT_MINOR_VERSION_ARB, profile.minor);
@@ -383,6 +384,9 @@ public:
}
int profileMask = profile.core ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
attribs.add(WGL_CONTEXT_PROFILE_MASK_ARB, profileMask);
+ if (profile.forwardCompatible) {
+ contextFlags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ }
}
} else if (profile.api == glprofile::API_GLES) {
if (checkExtension("WGL_EXT_create_context_es_profile", extensionsString)) {
@@ -403,7 +407,10 @@ public:
assert(0);
}
if (debug) {
- attribs.add(WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB);
+ contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB;
+ }
+ if (contextFlags) {
+ attribs.add(WGL_CONTEXT_FLAGS_ARB, contextFlags);
}
attribs.end();