From 757854c4b3c1b1b81d9f20a728e48adae0cf8a6a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 17 Feb 2020 16:32:38 +1100 Subject: [PATCH] viewer: detect nouveau and warn Nouveau has poor compatibility with Olive (and most other graphically intensive applications). For user benefit, we throw a warning messagebox if we detect the user is using Nouveau. --- app/widget/viewer/viewerglwidget.cpp | 31 ++++++++++++++++++++++++++++ app/widget/viewer/viewerglwidget.h | 11 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/app/widget/viewer/viewerglwidget.cpp b/app/widget/viewer/viewerglwidget.cpp index 7798731c9..2082d308a 100644 --- a/app/widget/viewer/viewerglwidget.cpp +++ b/app/widget/viewer/viewerglwidget.cpp @@ -28,6 +28,10 @@ #include "render/backend/opengl/openglrenderfunctions.h" #include "render/backend/opengl/openglshader.h" +#ifdef Q_OS_LINUX +bool ViewerGLWidget::nouveau_check_done_ = false; +#endif + ViewerGLWidget::ViewerGLWidget(QWidget *parent) : QOpenGLWidget(parent), texture_(0), @@ -132,6 +136,21 @@ void ViewerGLWidget::initializeGL() SetupColorProcessor(); connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(ContextCleanup()), Qt::DirectConnection); + +#ifdef Q_OS_LINUX + if (!nouveau_check_done_) { + const char* vendor = reinterpret_cast(context()->functions()->glGetString(GL_VENDOR)); + + if (!strcmp(vendor, "nouveau")) { + // Working with Qt widgets in this function segfaults, so we queue the messagebox for later + QMetaObject::invokeMethod(this, + "ShowNouveauWarning", + Qt::QueuedConnection); + } + + nouveau_check_done_ = true; + } +#endif } void ViewerGLWidget::paintGL() @@ -185,6 +204,18 @@ void ViewerGLWidget::RefreshColorPipeline() update(); } +#ifdef Q_OS_LINUX +void ViewerGLWidget::ShowNouveauWarning() +{ + QMessageBox::warning(this, + tr("Driver Warning"), + tr("Olive has detected your system is using the Nouveau graphics driver.\n\nThis driver is " + "known to have stability and performance issues with Olive. It is highly recommended " + "you install the proprietary NVIDIA driver before continuing to use Olive."), + QMessageBox::Ok); +} +#endif + void ViewerGLWidget::SetupColorProcessor() { if (!context()) { diff --git a/app/widget/viewer/viewerglwidget.h b/app/widget/viewer/viewerglwidget.h index 18f82bda1..3ec3ac5f9 100644 --- a/app/widget/viewer/viewerglwidget.h +++ b/app/widget/viewer/viewerglwidget.h @@ -186,6 +186,10 @@ private: */ QMatrix4x4 matrix_; +#ifdef Q_OS_LINUX + static bool nouveau_check_done_; +#endif + private slots: /** * @brief Slot to connect just before the OpenGL context is destroyed to clean up resources @@ -197,6 +201,13 @@ private slots: */ void RefreshColorPipeline(); +#ifdef Q_OS_LINUX + /** + * @brief Shows warning messagebox if Nouveau is detected + */ + void ShowNouveauWarning(); +#endif + }; #endif // VIEWERGLWIDGET_H