From 4982dfd5f5ec408a19de48a1ada98f91497db48d Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Tue, 15 Oct 2019 16:06:30 +0200 Subject: [PATCH] glx: Don't use sRGB configs on llvmpipe with depth 16 Summary: This is necessary to keep openQA working, which uses LLVMpipe as a renderer on a Cirrus device that operates in depth 16. LLVMpipe advertises 24/32 bit sRGB configurations on this setup, but they cannot be presented. CCBUG: 408594 Test Plan: Compile tested only. Reviewers: fvogt, #kwin, zzag Reviewed By: fvogt, #kwin, zzag Subscribers: romangg, sbergeron, fvogt, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D22203 --- plugins/platforms/x11/standalone/glxbackend.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index 1ae6ccd9ae..d745bb6f02 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -430,9 +430,24 @@ bool GlxBackend::initFbConfig() 0 }; + bool llvmpipe = false; + + // Note that we cannot use GLPlatform::driver() here, because it has not been initialized at this point + if (hasExtension(QByteArrayLiteral("GLX_MESA_query_renderer"))) { + const QByteArray device = glXQueryRendererStringMESA(display(), DefaultScreen(display()), 0, GLX_RENDERER_DEVICE_ID_MESA); + if (device.contains(QByteArrayLiteral("llvmpipe"))) { + llvmpipe = true; + } + } + // Try to find a double buffered sRGB capable configuration int count = 0; - GLXFBConfig *configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs_srgb, &count); + GLXFBConfig *configs = nullptr; + + // Don't request an sRGB configuration with LLVMpipe when the default depth is 16. See bug #408594. + if (!llvmpipe || Xcb::defaultDepth() > 16) { + configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs_srgb, &count); + } if (count == 0) { // Try to find a double buffered non-sRGB capable configuration