diff options
Diffstat (limited to 'src/egl/drivers/glx/egl_glx.c')
-rw-r--r-- | src/egl/drivers/glx/egl_glx.c | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 8ba70ba7a6..155caa413c 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -267,15 +267,17 @@ glx_token_to_visual_class(int visual_type) return None; } } -static GLboolean +static int get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, struct visual_attribs *attribs) { int visual_type; + int fbconfig_id; memset(attribs, 0, sizeof(struct visual_attribs)); - /* We don't use the GLX_FBCONFIG_ID here */ + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &fbconfig_id); + glXGetFBConfigAttrib(dpy, fbconfig, GLX_VISUAL_ID, &attribs->id); #if 0 @@ -294,11 +296,11 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level); glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type); if (!(attribs->render_type & GLX_RGBA_BIT)) - return GL_FALSE; + return 0; glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); if (!attribs->doubleBuffer) - return GL_FALSE; + return 0; glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo); glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers); @@ -332,7 +334,12 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); - return GL_TRUE; + if (attribs->id == 0) { + attribs->id = fbconfig_id; + return EGL_PBUFFER_BIT | EGL_PIXMAP_BIT; + } + + return EGL_WINDOW_BIT; } #endif @@ -344,6 +351,7 @@ create_configs(_EGLDisplay *disp, struct GLX_egl_driver *GLX_drv) int numVisuals; long mask; int i; + int egl_configs = 1; struct visual_attribs attribs; GLX_drv->fbconfigs = NULL; @@ -359,13 +367,15 @@ create_configs(_EGLDisplay *disp, struct GLX_egl_driver *GLX_drv) for (i = 0; i < numVisuals; i++) { struct GLX_egl_config *config; + int bit; - if (!get_fbconfig_attribs(disp->Xdpy, GLX_drv->fbconfigs[i], &attribs)) + bit = get_fbconfig_attribs(disp->Xdpy, GLX_drv->fbconfigs[i], &attribs); + if (!bit) continue; config = CALLOC_STRUCT(GLX_egl_config); - _eglInitConfig(&config->Base, i+1); + _eglInitConfig(&config->Base, (i+1)); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id); SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize); SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize); @@ -378,8 +388,7 @@ create_configs(_EGLDisplay *disp, struct GLX_egl_driver *GLX_drv) SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample); SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis); SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis); - SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, - (EGL_WINDOW_BIT | EGL_PBUFFER_BIT | EGL_PIXMAP_BIT)); + SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, bit); /* XXX possibly other things to init... */ @@ -403,7 +412,7 @@ xvisual: config = CALLOC_STRUCT(GLX_egl_config); - _eglInitConfig(&config->Base, i+1); + _eglInitConfig(&config->Base, (i+1)); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id); SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize); SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize); @@ -788,7 +797,20 @@ GLX_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) static _EGLProc GLX_eglGetProcAddress(const char *procname) { - return (_EGLProc)glXGetProcAddress((const GLubyte *)procname); + /* This is a bit of a hack to get at the gallium/Mesa state tracker + * function st_get_proc_address(). This will probably change at + * some point. + */ + _EGLProc (*get_proc_addr)(const char *procname); + get_proc_addr = dlsym(NULL, "st_get_proc_address"); + if (get_proc_addr) + return get_proc_addr(procname); + + get_proc_addr = glXGetProcAddress((const GLubyte *)procname); + if (get_proc_addr) + return get_proc_addr(procname); + + return (_EGLProc)dlsym(NULL, procname); } |