From 3d9a26cd8fc2a42aad3dda80ab065812ce8e2d13 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 16 Aug 2017 16:24:43 +0100 Subject: [PATCH] Fall back to creating a non-SRGB capable fbconfig. Refs #721 * In some cases it seems that no sRGB fbconfigs are available, so we fall back and create a non-SRGB one. This may render incorrectly but at least it should run without crashing. --- renderdoc/driver/gl/gl_hooks_linux.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/renderdoc/driver/gl/gl_hooks_linux.cpp b/renderdoc/driver/gl/gl_hooks_linux.cpp index ba8acef33..0c632121c 100644 --- a/renderdoc/driver/gl/gl_hooks_linux.cpp +++ b/renderdoc/driver/gl/gl_hooks_linux.cpp @@ -253,6 +253,8 @@ public: RDCERR("Unexpected window system %u", system); } + // GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB MUST be the last attrib so that we can remove it to retry + // if we find no srgb fbconfigs static int visAttribs[] = {GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, @@ -272,9 +274,26 @@ public: GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, True, 0}; + int numCfgs = 0; GLXFBConfig *fbcfg = glXChooseFBConfig_real(dpy, DefaultScreen(dpy), visAttribs, &numCfgs); + if(fbcfg == NULL) + { + const size_t len = ARRAY_COUNT(visAttribs); + if(visAttribs[len - 3] != GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB) + { + RDCERR( + "GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB isn't the last attribute, and no SRGB fbconfigs were " + "found!"); + } + else + { + visAttribs[len - 3] = 0; + fbcfg = glXChooseFBConfig_real(dpy, DefaultScreen(dpy), visAttribs, &numCfgs); + } + } + if(fbcfg == NULL) { RDCERR("Couldn't choose default framebuffer config");