]> git.cworth.org Git - apitrace/commitdiff
Add option to request an Opengl 3.2 core profile context.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 5 Dec 2011 09:44:52 +0000 (09:44 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 5 Dec 2011 09:44:52 +0000 (09:44 +0000)
glretrace.hpp
glretrace_cgl.cpp
glretrace_glx.cpp
glretrace_main.cpp
glretrace_wgl.cpp
glws.hpp
glws_egl_xlib.cpp
glws_glx.cpp

index 81b5d1eca36e1a476ecacfb394576365450d72a1..15035b2108143ba4d977c7932ed38f39afe0aa9a 100644 (file)
@@ -37,6 +37,7 @@ namespace glretrace {
 extern bool double_buffer;
 extern bool insideGlBeginEnd;
 extern trace::Parser parser;
+extern glws::Profile defaultProfile;
 extern glws::Visual *visual;
 extern glws::Drawable *drawable;
 extern glws::Context *context;
index 2feebc3303bc6aeacbe025f5ba12a9c5aa394f9e..0c5aa7355d9419b1e029efced880be173e3ff8d6 100644 (file)
@@ -70,7 +70,7 @@ getContext(unsigned long long ctx) {
     it = context_map.find(ctx);
     if (it == context_map.end()) {
         glws::Context *context;
-        context_map[ctx] = context = glws::createContext(visual, sharedContext);
+        context_map[ctx] = context = glws::createContext(visual, sharedContext, glretrace::defaultProfile);
         if (!sharedContext) {
             sharedContext = context;
         }
index d04bca6dff8ccf0fea11745fb919d96b79d719cc..749907ac7a4f520e416a877b6f0608575d5b6bc9 100644 (file)
@@ -62,7 +62,7 @@ getContext(unsigned long long context_ptr) {
     ContextMap::const_iterator it;
     it = context_map.find(context_ptr);
     if (it == context_map.end()) {
-        return (context_map[context_ptr] = glws::createContext(visual, NULL));
+        return (context_map[context_ptr] = glws::createContext(visual, NULL, glretrace::defaultProfile));
     }
 
     return it->second;
@@ -72,7 +72,7 @@ static void retrace_glXCreateContext(trace::Call &call) {
     unsigned long long orig_context = call.ret->toUIntPtr();
     glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
 
-    glws::Context *context = glws::createContext(glretrace::visual, share_context);
+    glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
     context_map[orig_context] = context;
 }
 
@@ -80,7 +80,7 @@ static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
     unsigned long long orig_context = call.ret->toUIntPtr();
     glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
 
-    glws::Context *context = glws::createContext(glretrace::visual, share_context);
+    glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
     context_map[orig_context] = context;
 }
 
@@ -134,7 +134,7 @@ static void retrace_glXCreateNewContext(trace::Call &call) {
     unsigned long long orig_context = call.ret->toUIntPtr();
     glws::Context *share_context = getContext(call.arg(3).toUIntPtr());
 
-    glws::Context *context = glws::createContext(glretrace::visual, share_context);
+    glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
     context_map[orig_context] = context;
 }
 
index 3c010d28ed7857e46d2524e82f8ac905827caed2..3bf9de890707ebce4f1582b9f8595801a57d6c14 100644 (file)
@@ -39,6 +39,7 @@ namespace glretrace {
 bool double_buffer = true;
 bool insideGlBeginEnd = false;
 trace::Parser parser;
+glws::Profile defaultProfile = glws::PROFILE_COMPAT;
 glws::Visual *visual = NULL;
 glws::Drawable *drawable = NULL;
 glws::Context *context = NULL;
@@ -248,6 +249,7 @@ static void usage(void) {
         "\n"
         "  -b           benchmark mode (no error checking or warning messages)\n"
         "  -c PREFIX    compare against snapshots\n"
+        "  -core        use core profile\n"
         "  -db          use a double buffer visual (default)\n"
         "  -sb          use a single buffer visual\n"
         "  -s PREFIX    take snapshots; `-` for PNM stdout output\n"
@@ -283,6 +285,8 @@ int main(int argc, char **argv)
         } else if (!strcmp(arg, "-D")) {
             dump_state = atoi(argv[++i]);
             retrace::verbosity = -2;
+        } else if (!strcmp(arg, "-core")) {
+            defaultProfile = glws::PROFILE_CORE;
         } else if (!strcmp(arg, "-db")) {
             double_buffer = true;
         } else if (!strcmp(arg, "-sb")) {
index 9cef80af802389bc8bccf283a6d8114f94e98253..243dfe0e14062fbc56a42a7c73fb8ba801fd566f 100644 (file)
@@ -56,7 +56,7 @@ getDrawable(unsigned long long hdc) {
 
 static void retrace_wglCreateContext(trace::Call &call) {
     unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *context = glws::createContext(glretrace::visual);
+    glws::Context *context = glws::createContext(glretrace::visual, NULL, glretrace::defaultProfile);
     context_map[orig_context] = context;
 }
 
@@ -114,7 +114,7 @@ static void retrace_wglShareLists(trace::Call &call) {
     glws::Context *old_context = context_map[hglrc2];
 
     glws::Context *new_context =
-        glws::createContext(old_context->visual, share_context);
+        glws::createContext(old_context->visual, share_context, glretrace::defaultProfile);
     if (new_context) {
         if (context == old_context) {
             glws::makeCurrent(drawable, new_context);
@@ -223,7 +223,7 @@ static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
         share_context = context_map[call.arg(1).toUIntPtr()];
     }
 
-    glws::Context *context = glws::createContext(glretrace::visual, share_context);
+    glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
     context_map[orig_context] = context;
 }
 
index 8d72a83357666174d435d7cb2180cf988e05163a..8294f6b320b0d5de288d958474a9e70ebfde8d7a 100644 (file)
--- a/glws.hpp
+++ b/glws.hpp
@@ -38,7 +38,8 @@ namespace glws {
 
 
 enum Profile {
-    PROFILE_COMPAT,
+    PROFILE_COMPAT = 0,
+    PROFILE_CORE,
     PROFILE_ES1,
     PROFILE_ES2,
 };
index d1277058c4c9fddc5b607ed99aa4f6c9fdccb42e..e383a532cd2e9eea00820414db5ebe1bd81c790e 100644 (file)
@@ -339,6 +339,9 @@ createContext(const Visual *_visual, Context *shareContext, Profile profile)
         load("libGL.so.1");
         eglBindAPI(EGL_OPENGL_API);
         break;
+    case PROFILE_CORE:
+        assert(0);
+        return NULL;
     case PROFILE_ES1:
         load("libGLESv1_CM.so.1");
         eglBindAPI(EGL_OPENGL_ES_API);
index db24b7f535f3b4bcef50bf0ba7c0508f78172650..a7f0b0fca49e7acfaed87625ec9f2f4e2a052b1a 100644 (file)
@@ -297,28 +297,49 @@ createContext(const Visual *_visual, Context *shareContext, Profile profile)
     GLXContext share_context = NULL;
     GLXContext context;
 
-    if (profile != PROFILE_COMPAT) {
-        return NULL;
-    }
-
     if (shareContext) {
         share_context = static_cast<GlxContext*>(shareContext)->context;
     }
 
     if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
         Attributes<int> attribs;
+        
         attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
         if (debug) {
             attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
         }
+
+        switch (profile) {
+        case PROFILE_COMPAT:
+            break;
+        case PROFILE_CORE:
+            // XXX: This will invariable return a 3.2 context, when supported.
+            // We probably should have a PROFILE_CORE_XX per version.
+            attribs.add(GLX_CONTEXT_MAJOR_VERSION_ARB, 3);
+            attribs.add(GLX_CONTEXT_MINOR_VERSION_ARB, 2);
+            attribs.add(GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB);
+            break;
+        default:
+            return NULL;
+        }
+        
         attribs.end();
 
         context = glXCreateContextAttribsARB(display, visual->fbconfig, share_context, True, attribs);
-    } else 
-           if (glxVersion >= 0x103) {
-        context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
     } else {
-        context = glXCreateContext(display, visual->visinfo, share_context, True);
+        if (profile != PROFILE_COMPAT) {
+            return NULL;
+        }
+
+        if (glxVersion >= 0x103) {
+            context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
+        } else {
+            context = glXCreateContext(display, visual->visinfo, share_context, True);
+        }
+    }
+
+    if (!context) {
+        return NULL;
     }
 
     return new GlxContext(visual, profile, context);