Bug 659932 - GLXtest process should check for GLX >= 1.3 before calling glXCreatePixmap - r=dbaron
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 19 Aug 2011 11:39:00 -0400
changeset 75536 39fd1683ee6f05e901c1515c9851b0027135f750
parent 75535 5c5eac0d8a45931279f952008e0546cf52e024f7
child 75537 7c3883a2fc31f31ed2ad6524c97012cdba74b6ba
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdbaron
bugs659932
milestone9.0a1
Bug 659932 - GLXtest process should check for GLX >= 1.3 before calling glXCreatePixmap - r=dbaron This gives cleaner error messages when trying to use GLX features on old GLXs.
toolkit/xre/glxtest.cpp
--- a/toolkit/xre/glxtest.cpp
+++ b/toolkit/xre/glxtest.cpp
@@ -109,16 +109,19 @@ static void glxtest()
   ///// Open libGL and load needed symbols /////
   void *libgl = dlopen("libGL.so.1", RTLD_LAZY);
   if (!libgl)
     fatal_error("Unable to load libGL.so.1");
 
   typedef GLXFBConfig* (* PFNGLXQUERYEXTENSION) (Display *, int *, int *);
   PFNGLXQUERYEXTENSION glXQueryExtension = cast<PFNGLXQUERYEXTENSION>(dlsym(libgl, "glXQueryExtension"));
 
+  typedef GLXFBConfig* (* PFNGLXQUERYVERSION) (Display *, int *, int *);
+  PFNGLXQUERYVERSION glXQueryVersion = cast<PFNGLXQUERYVERSION>(dlsym(libgl, "glXQueryVersion"));
+
   typedef GLXFBConfig* (* PFNGLXCHOOSEFBCONFIG) (Display *, int, const int *, int *);
   PFNGLXCHOOSEFBCONFIG glXChooseFBConfig = cast<PFNGLXCHOOSEFBCONFIG>(dlsym(libgl, "glXChooseFBConfig"));
 
   typedef XVisualInfo* (* PFNGLXGETVISUALFROMFBCONFIG) (Display *, GLXFBConfig);
   PFNGLXGETVISUALFROMFBCONFIG glXGetVisualFromFBConfig = cast<PFNGLXGETVISUALFROMFBCONFIG>(dlsym(libgl, "glXGetVisualFromFBConfig"));
 
   typedef GLXPixmap (* PFNGLXCREATEPIXMAP) (Display *, GLXFBConfig, Pixmap, const int *);
   PFNGLXCREATEPIXMAP glXCreatePixmap = cast<PFNGLXCREATEPIXMAP>(dlsym(libgl, "glXCreatePixmap"));
@@ -137,16 +140,17 @@ static void glxtest()
 
   typedef GLubyte* (* PFNGLGETSTRING) (GLenum);
   PFNGLGETSTRING glGetString = cast<PFNGLGETSTRING>(dlsym(libgl, "glGetString"));
 
   typedef void* (* PFNGLXGETPROCADDRESS) (const char *);
   PFNGLXGETPROCADDRESS glXGetProcAddress = cast<PFNGLXGETPROCADDRESS>(dlsym(libgl, "glXGetProcAddress"));
 
   if (!glXQueryExtension ||
+      !glXQueryVersion ||
       !glXChooseFBConfig ||
       !glXGetVisualFromFBConfig ||
       !glXCreatePixmap ||
       !glXCreateNewContext ||
       !glXMakeCurrent ||
       !glXDestroyPixmap ||
       !glXDestroyContext ||
       !glGetString ||
@@ -157,16 +161,24 @@ static void glxtest()
   ///// Open a connection to the X server /////
   Display *dpy = XOpenDisplay(NULL);
   if (!dpy)
     fatal_error("Unable to open a connection to the X server");
   
   ///// Check that the GLX extension is present /////
   if (!glXQueryExtension(dpy, NULL, NULL))
     fatal_error("GLX extension missing");
+  
+  ///// Check that the GLX version is >= 1.3, needed for glXCreatePixmap, bug 659932 /////
+  int majorVersion, minorVersion;
+  if (!glXQueryVersion(dpy, &majorVersion, &minorVersion))
+    fatal_error("Unable to query GLX version");
+
+  if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 3))
+    fatal_error("GLX version older than the required 1.3");
 
   XSetErrorHandler(x_error_handler);
 
   ///// Get a FBConfig and a visual /////
   int attribs[] = {
     GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
     GLX_X_RENDERABLE, True,
     0