Commit 9dd5c1a6 authored by Alvin Wong's avatar Alvin Wong

Add OpenGL warnings and make ANGLE default on Intel GPUs

Adds the ability to show some warning messages in the Display settings,
and also make ANGLE the default renderer with Intel graphics drivers.
This only affects Windows.

Maniphest Tasks: T7411
Differential Revision: https://phabricator.kde.org/D9435
parent b24d5222
......@@ -887,6 +887,24 @@ DisplaySettingsTab::DisplaySettingsTab(QWidget *parent, const char *name)
cmbFilterMode->removeItem(3);
}
}
const QStringList openglWarnings = KisOpenGL::getOpenGLWarnings();
if (openglWarnings.isEmpty()) {
lblOpenGLWarnings->setVisible(false);
} else {
QString text("<span style=\"color: yellow;\">&#x26A0;</span> ");
text.append(i18n("Warning(s):"));
text.append("<ul>");
Q_FOREACH (const QString &warning, openglWarnings) {
text.append("<li>");
text.append(warning.toHtmlEscaped());
text.append("</li>");
}
text.append("</ul>");
lblOpenGLWarnings->setText(text);
lblOpenGLWarnings->setVisible(true);
}
if (qApp->applicationName() == "kritasketch" || qApp->applicationName() == "kritagemini") {
grpOpenGL->setVisible(false);
grpOpenGL->setMaximumHeight(0);
......
......@@ -148,6 +148,19 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="lblOpenGLWarnings">
<property name="text">
<string notr="true">OpenGL Warnings</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -30,8 +30,11 @@
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QVector>
#include <QWindow>
#include <klocalizedstring.h>
#include <kis_debug.h>
#include <kis_config.h>
......@@ -56,6 +59,8 @@ namespace
QString debugText("OpenGL Info\n **OpenGL not initialized**");
QVector<KLocalizedString> openglWarningStrings;
void openglOnMessageLogged(const QOpenGLDebugMessage& debugMessage) {
qDebug() << "OpenGL:" << debugMessage;
}
......@@ -76,6 +81,11 @@ KisOpenGLPrivate::OpenGLCheckResult::OpenGLCheckResult(QOpenGLContext &context)
m_isOpenGLES = context.isOpenGLES();
}
void KisOpenGLPrivate::appendOpenGLWarningString(KLocalizedString warning)
{
openglWarningStrings << warning;
}
bool KisOpenGLPrivate::isDefaultFormatSet() {
return defaultFormatIsSet;
}
......@@ -216,6 +226,14 @@ const QString &KisOpenGL::getDebugText()
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()
......
......@@ -27,6 +27,7 @@
class QOpenGLContext;
class QString;
class QStringList;
/**
* This class manages a shared OpenGL context and provides utility
......@@ -73,6 +74,8 @@ public:
static const QString &getDebugText();
static QStringList getOpenGLWarnings();
static bool supportsLoD();
static bool hasOpenGL3();
static bool hasOpenGLES();
......
......@@ -24,6 +24,8 @@
class QDebug;
class QOpenGLContext;
class KLocalizedString;
namespace KisOpenGLPrivate
{
......@@ -99,6 +101,8 @@ void appendPlatformOpenGLDebugText(QDebug &debugOut);
void appendPlatformOpenGLDebugText(QDebug &debugOut) {}
#endif
void appendOpenGLWarningString(KLocalizedString warning);
bool isDefaultFormatSet();
} // namespace KisOpenGLPrivate
......
......@@ -25,6 +25,8 @@
#include <QStringList>
#include <QWindow>
#include <klocalizedstring.h>
#include <kis_debug.h>
#include <kis_config.h>
#include <KisLoggingManager.h>
......@@ -104,18 +106,45 @@ void specialOpenGLVendorFilter(WindowsOpenGLStatus &status, const OpenGLCheckRes
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 @@ void KisOpenGL::probeWindowsQpaOpenGL(int argc, char **argv, QString userRendere
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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment