From b1e0ef8ecd48ea89526a122c937590b798c54d37 Mon Sep 17 00:00:00 2001 From: Richard Grenville Date: Fri, 5 Jul 2013 23:21:05 +0800 Subject: [PATCH] Bug fix #124: GLX: Missing check on FBConfig X visual depth - Check FBConfig X visual depth, like Compiz, to fix issues with nvidia-drivers-325.08 . Thanks to guotsuan for reporting. --- src/opengl.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/opengl.c b/src/opengl.c index c9be5be..a788cd5 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -383,18 +383,31 @@ glx_update_fbconfig(session_t *ps) { .texture_tgts = 0, .y_inverted = false, }; + int id = (int) (pcur - pfbcfgs); int depth = 0, depth_alpha = 0, val = 0; if (Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_BUFFER_SIZE, &depth) || Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_ALPHA_SIZE, &depth_alpha)) { - printf_errf("(): Failed to retrieve buffer size and alpha size of FBConfig %d.", (int) (pcur - pfbcfgs)); + printf_errf("(): Failed to retrieve buffer size and alpha size of FBConfig %d.", id); continue; } if (Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_BIND_TO_TEXTURE_TARGETS_EXT, &fbinfo.texture_tgts)) { - printf_errf("(): Failed to retrieve BIND_TO_TEXTURE_TARGETS_EXT of FBConfig %d.", (int) (pcur - pfbcfgs)); + printf_errf("(): Failed to retrieve BIND_TO_TEXTURE_TARGETS_EXT of FBConfig %d.", id); continue; } + int visualdepth = 0; + { + XVisualInfo *pvi = glXGetVisualFromFBConfig(ps->dpy, *pcur); + if (!pvi) { + // On nvidia-drivers-325.08 this happens slightly too often... + // printf_errf("(): Failed to retrieve X Visual of FBConfig %d.", id); + continue; + } + visualdepth = pvi->depth; + cxfree(pvi); + } + bool rgb = false; bool rgba = false; @@ -407,12 +420,15 @@ glx_update_fbconfig(session_t *ps) { if (Success == glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_Y_INVERTED_EXT, &val)) fbinfo.y_inverted = val; - if ((depth - depth_alpha) < 32 && rgb) { - fbinfo.texture_fmt = GLX_TEXTURE_FORMAT_RGB_EXT; - glx_update_fbconfig_bydepth(ps, depth - depth_alpha, &fbinfo); + { + int tgtdpt = depth - depth_alpha; + if (tgtdpt == visualdepth && tgtdpt < 32 && rgb) { + fbinfo.texture_fmt = GLX_TEXTURE_FORMAT_RGB_EXT; + glx_update_fbconfig_bydepth(ps, tgtdpt, &fbinfo); + } } - if (rgba) { + if (depth == visualdepth && rgba) { fbinfo.texture_fmt = GLX_TEXTURE_FORMAT_RGBA_EXT; glx_update_fbconfig_bydepth(ps, depth, &fbinfo); }