diff options
-rw-r--r-- | gpu/command_buffer/service/x_utils.cc | 38 | ||||
-rw-r--r-- | gpu/command_buffer/service/x_utils.h | 2 | ||||
-rw-r--r-- | gpu/gpu.gyp | 2 | ||||
-rw-r--r-- | third_party/glew/include/GL/glxew.h | 85 | ||||
-rw-r--r-- | third_party/glew/src/glew.c | 64 |
5 files changed, 166 insertions, 25 deletions
diff --git a/gpu/command_buffer/service/x_utils.cc b/gpu/command_buffer/service/x_utils.cc index 78570de..d763755 100644 --- a/gpu/command_buffer/service/x_utils.cc +++ b/gpu/command_buffer/service/x_utils.cc @@ -4,13 +4,36 @@ // This class implements the XWindowWrapper class. +#include <dlfcn.h> + #include "gpu/command_buffer/service/precompile.h" #include "gpu/command_buffer/common/logging.h" #include "gpu/command_buffer/service/x_utils.h" namespace gpu { +// Some versions of NVIDIA's GL libGL.so include a broken version of +// dlopen/dlsym, and so linking it into chrome breaks it. So we dynamically +// load it, and use glew to dynamically resolve symbols. +// See http://code.google.com/p/chromium/issues/detail?id=16800 + +static bool g_glew_initialized = false; + bool XWindowWrapper::Initialize() { + if (!g_glew_initialized) { + void* handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + LOG(ERROR) << "Could not find libGL.so.1"; + return false; + } + + // Initializes context-independent parts of GLEW + if (glxewInit() != GLEW_OK) { + LOG(ERROR) << "GLXEW failed initialization"; + return false; + } + g_glew_initialized = true; + } XWindowAttributes attributes; XGetWindowAttributes(display_, window_, &attributes); XVisualInfo visual_info_template; @@ -32,6 +55,21 @@ bool XWindowWrapper::Initialize() { DLOG(ERROR) << "Couldn't create GL context."; return false; } + if (!MakeCurrent()) { + return false; + } + + // Initializes context-dependent parts of GLEW + if (glewInit() != GLEW_OK) { + LOG(ERROR) << "GLEW failed initialization"; + return false; + } + + if (!glewIsSupported("GL_VERSION_2_0")) { + LOG(ERROR) << "GL implementation doesn't support GL version 2.0"; + return false; + } + return true; } diff --git a/gpu/command_buffer/service/x_utils.h b/gpu/command_buffer/service/x_utils.h index ea478a6..5a4b517 100644 --- a/gpu/command_buffer/service/x_utils.h +++ b/gpu/command_buffer/service/x_utils.h @@ -7,7 +7,7 @@ #ifndef GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ #define GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ -#include <GL/glx.h> +#include <GL/glxew.h> #include "base/basictypes.h" #include "gpu/command_buffer/common/logging.h" diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index ee00088..8a51c05 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -54,7 +54,6 @@ '-L<(PRODUCT_DIR)', ], 'libraries': [ - '-lGL', '-lX11', ], }, @@ -255,6 +254,7 @@ 'command_buffer/service/x_utils.h', ], 'dependencies': [ + 'gl_libs', '../build/linux/system.gyp:gtk', ] }, diff --git a/third_party/glew/include/GL/glxew.h b/third_party/glew/include/GL/glxew.h index a29030d..ef89998 100644 --- a/third_party/glew/include/GL/glxew.h +++ b/third_party/glew/include/GL/glxew.h @@ -140,23 +140,41 @@ typedef struct __GLXcontextRec *GLXContext; typedef unsigned int GLXVideoDeviceNV; -extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); -extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); -extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); -extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); -extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); -extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); -extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); -extern void glXDestroyContext (Display *dpy, GLXContext ctx); -extern Bool glXIsDirect (Display *dpy, GLXContext ctx); -extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); -extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); -extern GLXContext glXGetCurrentContext (void); -extern GLXDrawable glXGetCurrentDrawable (void); -extern void glXWaitGL (void); -extern void glXWaitX (void); -extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); -extern void glXUseXFont (Font font, int first, int count, int listBase); +typedef Bool ( * PFNGLXQUERYEXTENSIONPROC) (Display *dpy, int *errorBase, int *eventBase); +typedef Bool ( * PFNGLXQUERYVERSIONPROC) (Display *dpy, int *major, int *minor); +typedef int ( * PFNGLXGETCONFIGPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value); +typedef XVisualInfo* ( * PFNGLXCHOOSEVISUALPROC) (Display *dpy, int screen, int *attribList); +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap); +typedef void ( * PFNGLXDESTROYGLXPIXMAPPROC) (Display *dpy, GLXPixmap pix); +typedef GLXContext ( * PFNGLXCREATECONTEXTPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); +typedef void ( * PFNGLXDESTROYCONTEXTPROC) (Display *dpy, GLXContext ctx); +typedef Bool ( * PFNGLXISDIRECTPROC) (Display *dpy, GLXContext ctx); +typedef void ( * PFNGLXCOPYCONTEXTPROC) (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); +typedef Bool ( * PFNGLXMAKECURRENTPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx); +typedef GLXContext ( * PFNGLXGETCURRENTCONTEXTPROC) (void); +typedef GLXDrawable ( * PFNGLXGETCURRENTDRAWABLEPROC) (void); +typedef void ( * PFNGLXWAITGLPROC) (void); +typedef void ( * PFNGLXWAITXPROC) (void); +typedef void ( * PFNGLXSWAPBUFFERSPROC) (Display *dpy, GLXDrawable drawable); +typedef void ( * PFNGLXUSEXFONTPROC) (Font font, int first, int count, int listBase); + +#define glXQueryExtension GLXEW_GET_FUN(__glewXQueryExtension) +#define glXQueryVersion GLXEW_GET_FUN(__glewXQueryVersion) +#define glXGetConfig GLXEW_GET_FUN(__glewXGetConfig) +#define glXChooseVisual GLXEW_GET_FUN(__glewXChooseVisual) +#define glXCreateGLXPixmap GLXEW_GET_FUN(__glewXCreateGLXPixmap) +#define glXDestroyGLXPixmap GLXEW_GET_FUN(__glewXDestroyGLXPixmap) +#define glXCreateContext GLXEW_GET_FUN(__glewXCreateContext) +#define glXDestroyContext GLXEW_GET_FUN(__glewXDestroyContext) +#define glXIsDirect GLXEW_GET_FUN(__glewXIsDirect) +#define glXCopyContext GLXEW_GET_FUN(__glewXCopyContext) +#define glXMakeCurrent GLXEW_GET_FUN(__glewXMakeCurrent) +#define glXGetCurrentContext GLXEW_GET_FUN(__glewXGetCurrentContext) +#define glXGetCurrentDrawable GLXEW_GET_FUN(__glewXGetCurrentDrawable) +#define glXWaitGL GLXEW_GET_FUN(__glewXWaitGL) +#define glXWaitX GLXEW_GET_FUN(__glewXWaitX) +#define glXSwapBuffers GLXEW_GET_FUN(__glewXSwapBuffers) +#define glXUseXFont GLXEW_GET_FUN(__glewXUseXFont) #define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) @@ -171,9 +189,13 @@ extern void glXUseXFont (Font font, int first, int count, int listBase); #define GLX_VERSION 0x2 #define GLX_EXTENSIONS 0x3 -extern const char* glXQueryExtensionsString (Display *dpy, int screen); -extern const char* glXGetClientString (Display *dpy, int name); -extern const char* glXQueryServerString (Display *dpy, int screen, int name); +typedef const char* (* PFNGLXQUERYEXTENSIONSSTRINGPROC) (Display *dpy, int screen); +typedef const char* (* PFNGLXGETCLIENTSTRINGPROC) (Display *dpy, int name); +typedef const char* (* PFNGLXQUERYSERVERSTRINGPROC) (Display *dpy, int screen, int name); + +#define glXQueryExtensionsString GLXEW_GET_FUN(__glewXQueryExtensionsString) +#define glXGetClientString GLXEW_GET_FUN(__glewXGetClientString) +#define glXQueryServerString GLXEW_GET_FUN(__glewXQueryServerString) #define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) @@ -1186,6 +1208,28 @@ typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, #define GLXEW_EXPORT extern #endif /* GLEW_MX */ +extern PFNGLXQUERYEXTENSIONPROC __glewXQueryExtension; +extern PFNGLXQUERYVERSIONPROC __glewXQueryVersion; +extern PFNGLXGETCONFIGPROC __glewXGetConfig; +extern PFNGLXCHOOSEVISUALPROC __glewXChooseVisual; +extern PFNGLXCREATEGLXPIXMAPPROC __glewXCreateGLXPixmap; +extern PFNGLXDESTROYGLXPIXMAPPROC __glewXDestroyGLXPixmap; +extern PFNGLXCREATECONTEXTPROC __glewXCreateContext; +extern PFNGLXDESTROYCONTEXTPROC __glewXDestroyContext; +extern PFNGLXISDIRECTPROC __glewXIsDirect; +extern PFNGLXCOPYCONTEXTPROC __glewXCopyContext; +extern PFNGLXMAKECURRENTPROC __glewXMakeCurrent; +extern PFNGLXGETCURRENTCONTEXTPROC __glewXGetCurrentContext; +extern PFNGLXGETCURRENTDRAWABLEPROC __glewXGetCurrentDrawable; +extern PFNGLXWAITGLPROC __glewXWaitGL; +extern PFNGLXWAITXPROC __glewXWaitX; +extern PFNGLXSWAPBUFFERSPROC __glewXSwapBuffers; +extern PFNGLXUSEXFONTPROC __glewXUseXFont; + +extern PFNGLXQUERYEXTENSIONSSTRINGPROC __glewXQueryExtensionsString; +extern PFNGLXGETCLIENTSTRINGPROC __glewXGetClientString; +extern PFNGLXQUERYSERVERSTRINGPROC __glewXQueryServerString; + extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; @@ -1384,6 +1428,7 @@ extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name); #define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) #define GLXEW_GET_FUN(x) x +extern GLenum glxewInit (); extern GLboolean glxewIsSupported (const char* name); #endif /* GLEW_MX */ diff --git a/third_party/glew/src/glew.c b/third_party/glew/src/glew.c index fb67781..9dae16f 100644 --- a/third_party/glew/src/glew.c +++ b/third_party/glew/src/glew.c @@ -8865,6 +8865,28 @@ GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST) #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +PFNGLXQUERYEXTENSIONPROC __glewXQueryExtension = NULL; +PFNGLXQUERYVERSIONPROC __glewXQueryVersion = NULL; +PFNGLXGETCONFIGPROC __glewXGetConfig = NULL; +PFNGLXCHOOSEVISUALPROC __glewXChooseVisual = NULL; +PFNGLXCREATEGLXPIXMAPPROC __glewXCreateGLXPixmap = NULL; +PFNGLXDESTROYGLXPIXMAPPROC __glewXDestroyGLXPixmap = NULL; +PFNGLXCREATECONTEXTPROC __glewXCreateContext = NULL; +PFNGLXDESTROYCONTEXTPROC __glewXDestroyContext = NULL; +PFNGLXISDIRECTPROC __glewXIsDirect = NULL; +PFNGLXCOPYCONTEXTPROC __glewXCopyContext = NULL; +PFNGLXMAKECURRENTPROC __glewXMakeCurrent = NULL; +PFNGLXGETCURRENTCONTEXTPROC __glewXGetCurrentContext = NULL; +PFNGLXGETCURRENTDRAWABLEPROC __glewXGetCurrentDrawable = NULL; +PFNGLXWAITGLPROC __glewXWaitGL = NULL; +PFNGLXWAITXPROC __glewXWaitX = NULL; +PFNGLXSWAPBUFFERSPROC __glewXSwapBuffers = NULL; +PFNGLXUSEXFONTPROC __glewXUseXFont = NULL; + +PFNGLXQUERYEXTENSIONSSTRINGPROC __glewXQueryExtensionsString = NULL; +PFNGLXGETCLIENTSTRINGPROC __glewXGetClientString = NULL; +PFNGLXQUERYSERVERSTRINGPROC __glewXQueryServerString = NULL; + PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL; PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL; @@ -9041,6 +9063,38 @@ GLboolean __GLXEW_SUN_video_resize = GL_FALSE; #endif /* !GLEW_MX */ +#ifdef GLX_VERSION_1_1 + +static GLboolean _glewInit_GLX_VERSION_1_1 (GLXEW_CONTEXT_ARG_DEF_INIT) { + GLboolean r = GL_FALSE; + + r = ((glXQueryExtension = (PFNGLXQUERYEXTENSIONPROC)glewGetProcAddress((const GLubyte*)"glXQueryExtension")) == NULL) || r; + r = ((glXQueryVersion = (PFNGLXQUERYVERSIONPROC)glewGetProcAddress((const GLubyte*)"glXQueryVersion")) == NULL) || r; + r = ((glXGetConfig = (PFNGLXGETCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXGetConfig")) == NULL) || r; + r = ((glXChooseVisual = (PFNGLXCHOOSEVISUALPROC)glewGetProcAddress((const GLubyte*)"glXChooseVisual")) == NULL) || r; + r = ((glXCreateGLXPixmap = (PFNGLXCREATEGLXPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmap")) == NULL) || r; + r = ((glXDestroyGLXPixmap = (PFNGLXDESTROYGLXPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXDestroyGLXPixmap")) == NULL) || r; + r = ((glXCreateContext = (PFNGLXCREATECONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCreateContext")) == NULL) || r; + r = ((glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXDestroyContext")) == NULL) || r; + r = ((glXIsDirect = (PFNGLXISDIRECTPROC)glewGetProcAddress((const GLubyte*)"glXIsDirect")) == NULL) || r; + r = ((glXCopyContext = (PFNGLXCOPYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCopyContext")) == NULL) || r; + r = ((glXMakeCurrent = (PFNGLXMAKECURRENTPROC)glewGetProcAddress((const GLubyte*)"glXMakeCurrent")) == NULL) || r; + r = ((glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentContext")) == NULL) || r; + r = ((glXGetCurrentDrawable = (PFNGLXGETCURRENTDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentDrawable")) == NULL) || r; + r = ((glXWaitGL = (PFNGLXWAITGLPROC)glewGetProcAddress((const GLubyte*)"glXWaitGL")) == NULL) || r; + r = ((glXWaitX = (PFNGLXWAITXPROC)glewGetProcAddress((const GLubyte*)"glXWaitX")) == NULL) || r; + r = ((glXSwapBuffers = (PFNGLXSWAPBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glXSwapBuffers")) == NULL) || r; + r = ((glXUseXFont = (PFNGLXUSEXFONTPROC)glewGetProcAddress((const GLubyte*)"glXUseXFont")) == NULL) || r; + + r = ((glXQueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXQueryExtensionsString")) == NULL) || r; + r = ((glXGetClientString = (PFNGLXGETCLIENTSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXGetClientString")) == NULL) || r; + r = ((glXQueryServerString = (PFNGLXQUERYSERVERSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXQueryServerString")) == NULL) || r; + + return r; +} + +#endif + #ifdef GLX_VERSION_1_2 static GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT) @@ -9546,7 +9600,13 @@ static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) /* ------------------------------------------------------------------------ */ -typedef const char* ( * PFNGLXGETCLIENTSTRINGPROC) (Display *dpy, int name); +#if !defined(GLEW_MX) +GLenum glxewInit () { + if (_glewInit_GLX_VERSION_1_1(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY; + + return GLEW_OK; +} +#endif GLboolean glxewGetExtension (const char* name) { @@ -9573,8 +9633,6 @@ GLboolean glxewGetExtension (const char* name) return GL_FALSE; } -typedef Bool (* PFNGLXQUERYVERSIONPROC) (Display *dpy, int *major, int *minor); - GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) { int major, minor; |