[gtk+] x11/gl: Do not specify the GLX context version



commit a834078804de592a9d77974b85ddfde03a86a94b
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Jan 10 00:07:51 2015 +0000

    x11/gl: Do not specify the GLX context version
    
    If we use GDK_GL_PROFILE_3_2_CORE we are asking for a core profile
    according to the GLX_ARB_create_context_profile extension. For that,
    we pass the GLX_CONTEXT_CORE_PROFILE_BIT_ARB value for the
    GLX_CONTEXT_PROFILE_MASK_ARB attribute.
    
    The specification for the extension says that:
    
      If the requested OpenGL version is less than 3.2,
      GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
      of the context is determined solely by the requested version.
    
    Since we're asking for a core profile, we assume a GL version greater
    than or equal to 3.2; thus, we don't need to specify the
    GLX_CONTEXT_MAJOR_VERSION_ARB or the GLX_CONTEXT_MINOR_VERSION_ARB
    attributes, and instead just rely on whatever version GLX gives us.
    
    This seems to work around a strange issue in Mesa; if we ask for a core
    profile and any version > 3.0, we get broken rendering on any shared
    context we create.

 gdk/x11/gdkglcontext-x11.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 47de80c..03a2220 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -739,10 +739,19 @@ create_gl3_context (GdkDisplay   *display,
                     GLXFBConfig   config,
                     GdkGLContext *share)
 {
+  /* There are no profiles before OpenGL 3.2.
+   *
+   * The GLX_ARB_create_context_profile spec says:
+   *
+   *   If the requested OpenGL version is less than 3.2,
+   *   GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
+   *   of the context is determined solely by the requested version.
+   *
+   * Which means we can ask for the CORE_PROFILE_BIT without asking for
+   * a 3.2 version.
+   */
   static const int attrib_list[] = {
-    GLX_CONTEXT_PROFILE_MASK_ARB,  GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
-    GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
-    GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+    GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
     None,
   };
 
@@ -1074,17 +1083,21 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
 
   dpy = gdk_x11_display_get_xdisplay (display);
 
-  /* we check for the GLX_ARB_create_context_profile extension
-   * while validating the PixelFormat.
+  /* we check for the presence of the GLX_ARB_create_context_profile
+   * extension before checking for a GLXFBConfig.
    */
   if (profile == GDK_GL_PROFILE_3_2_CORE)
-    glx_context = create_gl3_context (display, config, share);
+    {
+      GDK_NOTE (OPENGL, g_print ("Creating core GLX context\n"));
+      glx_context = create_gl3_context (display, config, share);
+    }
   else
     {
       /* GDK_GL_PROFILE_DEFAULT is currently
        * equivalent to the LEGACY profile
        */
       profile = GDK_GL_PROFILE_LEGACY;
+      GDK_NOTE (OPENGL, g_print ("Creating legacy GLX context\n"));
       glx_context = create_gl_context (display, config, share);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]