diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.cc --- a/libs/ui/dialogs/kis_dlg_preferences.cc +++ b/libs/ui/dialogs/kis_dlg_preferences.cc @@ -813,6 +813,24 @@ cmbFilterMode->removeItem(3); } } + + const QStringList openglWarnings = KisOpenGL::getOpenGLWarnings(); + if (openglWarnings.isEmpty()) { + lblOpenGLWarnings->setVisible(false); + } else { + QString text(" "); + text.append(i18n("Warning(s):")); + text.append(""); + lblOpenGLWarnings->setText(text); + lblOpenGLWarnings->setVisible(true); + } + if (qApp->applicationName() == "kritasketch" || qApp->applicationName() == "kritagemini") { grpOpenGL->setVisible(false); grpOpenGL->setMaximumHeight(0); diff --git a/libs/ui/forms/wdgdisplaysettings.ui b/libs/ui/forms/wdgdisplaysettings.ui --- a/libs/ui/forms/wdgdisplaysettings.ui +++ b/libs/ui/forms/wdgdisplaysettings.ui @@ -266,6 +266,19 @@ + + + + OpenGL Warnings + + + Qt::RichText + + + true + + + diff --git a/libs/ui/opengl/kis_opengl.h b/libs/ui/opengl/kis_opengl.h --- a/libs/ui/opengl/kis_opengl.h +++ b/libs/ui/opengl/kis_opengl.h @@ -27,6 +27,7 @@ class QOpenGLContext; class QString; +class QStringList; /** * This class manages a shared OpenGL context and provides utility @@ -73,6 +74,8 @@ static const QString &getDebugText(); + static QStringList getOpenGLWarnings(); + static bool supportsLoD(); static bool hasOpenGL3(); static bool hasOpenGLES(); diff --git a/libs/ui/opengl/kis_opengl.cpp b/libs/ui/opengl/kis_opengl.cpp --- a/libs/ui/opengl/kis_opengl.cpp +++ b/libs/ui/opengl/kis_opengl.cpp @@ -30,8 +30,11 @@ #include #include #include +#include #include +#include + #include #include @@ -56,6 +59,8 @@ QString debugText("OpenGL Info\n **OpenGL not initialized**"); + QVector openglWarningStrings; + void openglOnMessageLogged(const QOpenGLDebugMessage& debugMessage) { qDebug() << "OpenGL:" << debugMessage; } @@ -76,6 +81,11 @@ m_isOpenGLES = context.isOpenGLES(); } +void KisOpenGLPrivate::appendOpenGLWarningString(KLocalizedString warning) +{ + openglWarningStrings << warning; +} + bool KisOpenGLPrivate::isDefaultFormatSet() { return defaultFormatIsSet; } @@ -216,6 +226,14 @@ return debugText; } +QStringList KisOpenGL::getOpenGLWarnings() { + QStringList strings; + Q_FOREACH (const KLocalizedString &item, openglWarningStrings) { + strings << item.toString(); + } + return strings; +} + // XXX Temporary function to allow LoD on OpenGL3 without triggering // all of the other 3.2 functionality, can be removed once we move to Qt5.7 bool KisOpenGL::supportsLoD() diff --git a/libs/ui/opengl/kis_opengl_p.h b/libs/ui/opengl/kis_opengl_p.h --- a/libs/ui/opengl/kis_opengl_p.h +++ b/libs/ui/opengl/kis_opengl_p.h @@ -24,6 +24,8 @@ class QDebug; class QOpenGLContext; +class KLocalizedString; + namespace KisOpenGLPrivate { @@ -101,6 +103,8 @@ void appendPlatformOpenGLDebugText(QDebug &debugOut) {} #endif +void appendOpenGLWarningString(KLocalizedString warning); + bool isDefaultFormatSet(); } // namespace KisOpenGLPrivate diff --git a/libs/ui/opengl/kis_opengl_win.cpp b/libs/ui/opengl/kis_opengl_win.cpp --- a/libs/ui/opengl/kis_opengl_win.cpp +++ b/libs/ui/opengl/kis_opengl_win.cpp @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -104,18 +106,45 @@ if (!status.supportsAngleD3D11) { return; } - // HACK: Make ANGLE the preferred renderer for Intel driver versions - // between build 4636 and 4729 (exclusive) due to an UI offset bug. - // See https://communities.intel.com/thread/116003 - // (Build 4636 is known to work from some test results) + + // Special blacklisting of OpenGL/ANGLE is tracked on: + // https://phabricator.kde.org/T7411 + + // HACK: Specificly detect for Intel driver build number + // See https://www.intel.com/content/www/us/en/support/articles/000005654/graphics-drivers.html if (checkResult.rendererString().startsWith("Intel")) { + KLocalizedString knownBadIntelWarning = ki18n("The Intel graphics driver in use is known to have issues with OpenGL."); + KLocalizedString grossIntelWarning = ki18n( + "Intel graphics drivers tend to have issues with OpenGL so ANGLE will be used by default. " + "You may manually switch to OpenGL but it is not guaranteed to work properly." + ); QRegularExpression regex("\\b\\d{2}\\.\\d{2}\\.\\d{2}\\.(\\d{4})\\b"); QRegularExpressionMatch match = regex.match(checkResult.driverVersionString()); if (match.hasMatch()) { int driverBuild = match.captured(1).toInt(); if (driverBuild > 4636 && driverBuild < 4729) { + // Make ANGLE the preferred renderer for Intel driver versions + // between build 4636 and 4729 (exclusive) due to an UI offset bug. + // See https://communities.intel.com/thread/116003 + // (Build 4636 is known to work from some test results) qDebug() << "Detected Intel driver build between 4636 and 4729, making ANGLE the preferred renderer"; status.overridePreferAngle = true; + appendOpenGLWarningString(knownBadIntelWarning); + } else if (driverBuild == 4358) { + // There are several reports on a bug where the canvas is not being + // updated properly which has debug info pointing to this build. + qDebug() << "Detected Intel driver build 4358, making ANGLE the preferred renderer"; + status.overridePreferAngle = true; + appendOpenGLWarningString(knownBadIntelWarning); + } else { + // Intel tends to randomly break OpenGL in some of their new driver + // builds, therefore we just shouldn't use OpenGL by default to + // reduce bug report noises. + qDebug() << "Detected Intel driver, making ANGLE the preferred renderer"; + status.overridePreferAngle = true; + if (status.supportsDesktopGL) { + appendOpenGLWarningString(grossIntelWarning); + } } } } @@ -215,11 +244,26 @@ windowsOpenGLStatus.supportsAngleD3D11 = checkResultAngle && checkIsSupportedAngleD3D11(*checkResultAngle); + if (!windowsOpenGLStatus.supportsDesktopGL) { + appendOpenGLWarningString(ki18n("The graphics driver in use does not meet the OpenGL requirements.")); + } else if (windowsOpenGLStatus.isQtPreferAngle) { + appendOpenGLWarningString(ki18n("The graphics driver in use may not work well with OpenGL.")); + } + // HACK: Filter specific buggy drivers not handled by Qt OpenGL buglist if (checkResultDesktopGL) { specialOpenGLVendorFilter(windowsOpenGLStatus, *checkResultDesktopGL); } + if (windowsOpenGLStatus.supportsAngleD3D11 + && (checkResultAngle->rendererString().contains("Software Adapter") + || checkResultAngle->rendererString().contains("Microsoft Basic Render Driver"))) { + appendOpenGLWarningString(ki18n( + "ANGLE is using a software Direct3D renderer, which is not hardware-accelerated and may be very slow. " + "This can happen if the graphics drivers are not properly installed, or when using a Remote Desktop session." + )); + } + userRendererConfig = convertConfigToOpenGLRenderer(userRendererConfigString); if ((userRendererConfig == RendererDesktopGL && !windowsOpenGLStatus.supportsDesktopGL) || (userRendererConfig == RendererAngle && !windowsOpenGLStatus.supportsAngleD3D11)) {