From 99204847e95485e688ff68f4bbc44b059c8fc9c7 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 28 Aug 2012 15:38:08 -0400 Subject: [PATCH] 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. --- toolkit/xre/glxtest.cpp | 47 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/toolkit/xre/glxtest.cpp b/toolkit/xre/glxtest.cpp index dd6dfda077b..aebaf6a701e 100644 --- a/toolkit/xre/glxtest.cpp +++ b/toolkit/xre/glxtest.cpp @@ -110,14 +110,11 @@ static void glxtest() typedef GLXFBConfig* (* PFNGLXQUERYVERSION) (Display *, int *, int *); PFNGLXQUERYVERSION glXQueryVersion = cast(dlsym(libgl, "glXQueryVersion")); - typedef GLXFBConfig* (* PFNGLXCHOOSEFBCONFIG) (Display *, int, const int *, int *); - PFNGLXCHOOSEFBCONFIG glXChooseFBConfig = cast(glXGetProcAddress("glXChooseFBConfig")); + typedef XVisualInfo* (* PFNGLXCHOOSEVISUAL) (Display *, int, int *); + PFNGLXCHOOSEVISUAL glXChooseVisual = cast(glXGetProcAddress("glXChooseVisual")); - typedef XVisualInfo* (* PFNGLXGETVISUALFROMFBCONFIG) (Display *, GLXFBConfig); - PFNGLXGETVISUALFROMFBCONFIG glXGetVisualFromFBConfig = cast(glXGetProcAddress("glXGetVisualFromFBConfig")); - - typedef GLXContext (* PFNGLXCREATENEWCONTEXT) (Display *, GLXFBConfig, int, GLXContext, Bool); - PFNGLXCREATENEWCONTEXT glXCreateNewContext = cast(glXGetProcAddress("glXCreateNewContext")); + typedef GLXContext (* PFNGLXCREATECONTEXT) (Display *, XVisualInfo *, GLXContext, Bool); + PFNGLXCREATECONTEXT glXCreateContext = cast(glXGetProcAddress("glXCreateContext")); typedef Bool (* PFNGLXMAKECURRENT) (Display*, GLXDrawable, GLXContext); PFNGLXMAKECURRENT glXMakeCurrent = cast(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);