Bug 680644 - Simplify glxtest and make it similar to glxinfo to avoid X server crashes - r=karlt

We were getting orange B's due to X server crashes on builders.
This commit is contained in:
Benoit Jacob 2012-08-28 15:38:08 -04:00
parent c505fabbd6
commit 99204847e9

View File

@ -110,14 +110,11 @@ static void glxtest()
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>(glXGetProcAddress("glXChooseFBConfig"));
typedef XVisualInfo* (* PFNGLXCHOOSEVISUAL) (Display *, int, int *);
PFNGLXCHOOSEVISUAL glXChooseVisual = cast<PFNGLXCHOOSEVISUAL>(glXGetProcAddress("glXChooseVisual"));
typedef XVisualInfo* (* PFNGLXGETVISUALFROMFBCONFIG) (Display *, GLXFBConfig);
PFNGLXGETVISUALFROMFBCONFIG glXGetVisualFromFBConfig = cast<PFNGLXGETVISUALFROMFBCONFIG>(glXGetProcAddress("glXGetVisualFromFBConfig"));
typedef GLXContext (* PFNGLXCREATENEWCONTEXT) (Display *, GLXFBConfig, int, GLXContext, Bool);
PFNGLXCREATENEWCONTEXT glXCreateNewContext = cast<PFNGLXCREATENEWCONTEXT>(glXGetProcAddress("glXCreateNewContext"));
typedef GLXContext (* PFNGLXCREATECONTEXT) (Display *, XVisualInfo *, GLXContext, Bool);
PFNGLXCREATECONTEXT glXCreateContext = cast<PFNGLXCREATECONTEXT>(glXGetProcAddress("glXCreateContext"));
typedef Bool (* PFNGLXMAKECURRENT) (Display*, GLXDrawable, GLXContext);
PFNGLXMAKECURRENT glXMakeCurrent = cast<PFNGLXMAKECURRENT>(glXGetProcAddress("glXMakeCurrent"));
@ -130,9 +127,8 @@ static void glxtest()
if (!glXQueryExtension ||
!glXQueryVersion ||
!glXChooseFBConfig ||
!glXGetVisualFromFBConfig ||
!glXCreateNewContext ||
!glXChooseVisual ||
!glXCreateContext ||
!glXMakeCurrent ||
!glXDestroyContext ||
!glGetString)
@ -150,31 +146,33 @@ static void glxtest()
XSetErrorHandler(x_error_handler);
///// Get a FBConfig and a visual /////
int numReturned;
GLXFBConfig *fbConfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), NULL, &numReturned );
if (!fbConfigs)
fatal_error("No FBConfigs found");
XVisualInfo *vInfo = glXGetVisualFromFBConfig(dpy, fbConfigs[0]);
///// Get a visual /////
int attribs[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
XVisualInfo *vInfo = glXChooseVisual(dpy, DefaultScreen(dpy), attribs);
if (!vInfo)
fatal_error("No visual found for first FBConfig");
fatal_error("No visuals found");
// using a X11 Window instead of a GLXPixmap does not crash
// fglrx in indirect rendering. bug 680644
Window win1;
Window window;
XSetWindowAttributes swa;
swa.colormap = XCreateColormap(dpy, RootWindow(dpy, vInfo->screen),
vInfo->visual, AllocNone);
swa.border_pixel = 0;
win1 = XCreateWindow(dpy, RootWindow(dpy, vInfo->screen),
10, 10, 16, 16,
window = XCreateWindow(dpy, RootWindow(dpy, vInfo->screen),
0, 0, 16, 16,
0, vInfo->depth, InputOutput, vInfo->visual,
CWBorderPixel | CWColormap, &swa);
///// Get a GL context and make it current //////
GLXContext context = glXCreateNewContext(dpy, fbConfigs[0], GLX_RGBA_TYPE, NULL, True);
glXMakeCurrent(dpy, win1, context);
GLXContext context = glXCreateContext(dpy, vInfo, NULL, True);
glXMakeCurrent(dpy, window, context);
///// Look for this symbol to determine texture_from_pixmap support /////
void* glXBindTexImageEXT = glXGetProcAddress("glXBindTexImageEXT");
@ -203,7 +201,8 @@ static void glxtest()
///// possible. Also we want to check that we're able to do that too without generating X errors.
glXMakeCurrent(dpy, None, NULL); // must release the GL context before destroying it
glXDestroyContext(dpy, context);
XDestroyWindow(dpy,win1);
XDestroyWindow(dpy, window);
XFreeColormap(dpy, swa.colormap);
XCloseDisplay(dpy);
dlclose(libgl);