From bbae1c2ae7ae3cad3c48d6903290f6c3d424e655 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 2 Feb 2022 13:57:02 +0300 Subject: [PATCH] Add AllowLinuxNvidiaOpenGL option. --- ui/gl/gl_detection.cpp | 19 +++++++++++++++++-- ui/gl/gl_detection.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index b2e3e13..7c7ea3f 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -9,6 +9,7 @@ #include "ui/gl/gl_shader.h" #include "ui/integration.h" #include "base/debug_log.h" +#include "base/options.h" #include #include @@ -34,6 +35,14 @@ bool ForceDisabled/* = false*/; ANGLE ResolvedANGLE = ANGLE::Auto; #endif // Q_OS_WIN +base::options::toggle AllowLinuxNvidiaOpenGL({ + .id = kOptionAllowLinuxNvidiaOpenGL, + .name = "Allow OpenGL on the NVIDIA drivers (Linux)", + .description = "Qt+OpenGL have problems on Linux with NVIDIA drivers.", + .scope = base::options::linux, + .restartRequired = true, +}); + void CrashCheckStart() { auto f = QFile(Integration::Instance().openglCheckFilePath()); if (f.open(QIODevice::WriteOnly)) { @@ -44,6 +53,8 @@ void CrashCheckStart() { } // namespace +const char kOptionAllowLinuxNvidiaOpenGL[] = "allow-linux-nvidia-opengl"; + Capabilities CheckCapabilities(QWidget *widget) { if (ForceDisabled) { LOG_ONCE(("OpenGL: Force-disabled.")); @@ -169,8 +180,12 @@ Capabilities CheckCapabilities(QWidget *widget) { #ifdef Q_OS_LINUX if (version && QByteArray(version).contains("NVIDIA")) { // https://github.com/telegramdesktop/tdesktop/issues/16830 - LOG_ONCE(("OpenGL: Disable on NVIDIA driver on Linux.")); - return false; + if (AllowLinuxNvidiaOpenGL.value()) { + LOG_ONCE(("OpenGL: Allow on NVIDIA driver (experimental).")); + } else { + LOG_ONCE(("OpenGL: Disable on NVIDIA driver on Linux.")); + return false; + } } #endif // Q_OS_LINUX diff --git a/ui/gl/gl_detection.h b/ui/gl/gl_detection.h index b197bcc..45978ae 100644 --- a/ui/gl/gl_detection.h +++ b/ui/gl/gl_detection.h @@ -12,6 +12,8 @@ class QOpenGLContext; namespace Ui::GL { +extern const char kOptionAllowLinuxNvidiaOpenGL[]; + enum class Backend { Raster, OpenGL,