summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helpers/glprofile.hpp7
-rwxr-xr-xretrace/glretrace_main.cpp16
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");