From fbc0ccce3fb36c2c76a977a6e6f37d8e76a800b0 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 9f6ad4fa9..b0f61caaa 100644 --- a/renderdoc/driver/gl/gl_hooks_linux.cpp +++ b/renderdoc/driver/gl/gl_hooks_linux.cpp @@ -254,6 +254,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, @@ -273,9 +275,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");