diff options
author | José Fonseca <jfonseca@vmware.com> | 2015-01-05 20:22:44 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2015-01-05 20:22:44 +0000 |
commit | c49a6953b0f5cbfa2d20de4246a87efdc3b0aa52 (patch) | |
tree | 3f93691cd60bf40276f14dd40b9284f20476e0ca | |
parent | a44df7a4fb533e904e4092ca6d67c4cfdf90dab6 (diff) |
glretrace: Ensure we get a matching context.
-rw-r--r-- | helpers/glprofile.hpp | 7 | ||||
-rwxr-xr-x | retrace/glretrace_main.cpp | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp index dc35400b..1ff922cb 100644 --- a/helpers/glprofile.hpp +++ b/helpers/glprofile.hpp @@ -65,6 +65,13 @@ struct Profile { (major == refMajor && minor >= refMinor); } + inline bool + matches(const Profile expected) const { + return api == expected.api && + versionGreaterOrEqual(expected.major, expected.minor) && + core == expected.core; + } + // Comparison operator, mainly for use in std::map inline bool operator == (const Profile & other) const { diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp index 714295f5..d60c4051 100755 --- a/retrace/glretrace_main.cpp +++ b/retrace/glretrace_main.cpp @@ -336,12 +336,26 @@ clientWaitSync(trace::Call &call, GLsync sync, GLbitfield flags, GLuint64 timeou } +/* + * Called the first time a context is made current. + */ void initContext() { glretrace::Context *currentContext = glretrace::getCurrentContext(); + assert(currentContext); + + /* Ensure we got a matching profile. + * + * In particular on MacOSX, there is no other way. + */ + glprofile::Profile expectedProfile = currentContext->wsContext->profile; + glprofile::Profile currentProfile = glprofile::getCurrentContextProfile(); + if (!currentProfile.matches(expectedProfile)) { + std::cerr << "error: bad context version: expected " << expectedProfile << ", got " << currentProfile << "\n"; + exit(1); + } /* Ensure we have adequate extension support */ - assert(currentContext); supportsTimestamp = currentContext->hasExtension("GL_ARB_timer_query"); supportsElapsed = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp; supportsOcclusion = currentContext->hasExtension("GL_ARB_occlusion_query"); |