Add an OpenGL information tab to Debug Console

Summary:
The new tab shows the information from GLPlatform similar to how it is
shown in the supportInformation. In addition it also lists all available
openGL and EGL/GLX extensions. For that kwinglutils is extended by
functions to return the lists of extensions.

Reviewers: #kwin, #plasma, bshah

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2385
icc-effect-5.14.5
Martin Gräßlin 2016-08-10 08:25:20 +02:00
parent 915af29886
commit dad7004dbb
5 changed files with 282 additions and 7 deletions

View File

@ -29,6 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "libinput/connection.h"
#include "libinput/device.h"
#endif
#include <kwinglplatform.h>
#include <kwinglutils.h>
#include "ui_debug_console.h"
@ -485,10 +487,54 @@ DebugConsole::DebugConsole()
// for X11
setWindowFlags(Qt::X11BypassWindowManagerHint);
initGLTab();
}
DebugConsole::~DebugConsole() = default;
void DebugConsole::initGLTab()
{
GLPlatform *gl = GLPlatform::instance();
if (!gl) {
m_ui->noOpenGLLabel->setVisible(true);
m_ui->glInfoScrollArea->setVisible(false);
return;
}
m_ui->noOpenGLLabel->setVisible(false);
m_ui->glInfoScrollArea->setVisible(true);
m_ui->glVendorStringLabel->setText(QString::fromLocal8Bit(gl->glVendorString()));
m_ui->glRendererStringLabel->setText(QString::fromLocal8Bit(gl->glRendererString()));
m_ui->glVersionStringLabel->setText(QString::fromLocal8Bit(gl->glVersionString()));
m_ui->glslVersionStringLabel->setText(QString::fromLocal8Bit(gl->glShadingLanguageVersionString()));
m_ui->glDriverLabel->setText(GLPlatform::driverToString(gl->driver()));
m_ui->glGPULabel->setText(GLPlatform::chipClassToString(gl->chipClass()));
m_ui->glVersionLabel->setText(GLPlatform::versionToString(gl->glVersion()));
m_ui->glslLabel->setText(GLPlatform::versionToString(gl->glslVersion()));
auto extensionsString = [] (const QList<QByteArray> &extensions) {
QString text = QStringLiteral("<ul>");
for (auto extension : extensions) {
text.append(QStringLiteral("<li>%1</li>").arg(QString::fromLocal8Bit(extension)));
}
text.append(QStringLiteral("</ul>"));
return text;
};
if (gl->platformInterface() == EglPlatformInterface) {
m_ui->eglExtensionsBox->setVisible(true);
m_ui->glxExtensionsBox->setVisible(false);
m_ui->eglExtensionsLabel->setText(extensionsString(eglExtensions()));
} else {
m_ui->eglExtensionsBox->setVisible(false);
m_ui->glxExtensionsBox->setVisible(true);
m_ui->glxExtensionsLabel->setText(extensionsString(glxExtensions()));
}
m_ui->openGLExtensionsLabel->setText(extensionsString(openGLExtensions()));
}
DebugConsoleDelegate::DebugConsoleDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{

View File

@ -102,6 +102,8 @@ public:
virtual ~DebugConsole();
private:
void initGLTab();
QScopedPointer<Ui::DebugConsole> m_ui;
QScopedPointer<DebugConsoleFilter> m_inputFilter;
};

View File

@ -94,6 +94,214 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>OpenGL</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="noOpenGLLabel">
<property name="text">
<string>No OpenGL compositor running</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="glInfoScrollArea">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>471</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="driverInfoBox">
<property name="title">
<string>OpenGL (ES) driver information</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Vendor:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Renderer:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Shading Language Version:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Driver:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>GPU class:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>OpenGL Version:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>GLSL Version:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="glVendorStringLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="glRendererStringLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="glVersionStringLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="glslVersionStringLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="glDriverLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="glGPULabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="glVersionLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="glslLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="eglExtensionsBox">
<property name="title">
<string>EGL Extensions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="eglExtensionsLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="glxExtensionsBox">
<property name="title">
<string>GLX Extensions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="glxExtensionsLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="glExtensionsBox">
<property name="title">
<string>OpenGL (ES) Extensions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="openGLExtensionsLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -72,8 +72,8 @@ static int glXVersion;
static int eglVersion;
// List of all supported GL, EGL and GLX extensions
static QList<QByteArray> glExtensions;
static QList<QByteArray> glxExtensions;
static QList<QByteArray> eglExtensions;
static QList<QByteArray> s_glxExtensions;
static QList<QByteArray> s_eglExtensions;
int glTextureUnitsCount;
@ -88,7 +88,7 @@ void initGLX()
glXVersion = MAKE_GL_VERSION(major, minor, 0);
// Get list of supported GLX extensions
const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen());
glxExtensions = string.split(' ');
s_glxExtensions = string.split(' ');
glxResolveFunctions();
#endif
}
@ -102,7 +102,7 @@ void initEGL()
eglInitialize(dpy, &major, &minor);
eglVersion = MAKE_GL_VERSION(major, minor, 0);
const QByteArray string = eglQueryString(dpy, EGL_EXTENSIONS);
eglExtensions = string.split(' ');
s_eglExtensions = string.split(' ');
eglResolveFunctions();
}
@ -152,8 +152,8 @@ void cleanupGL()
GLPlatform::cleanup();
glExtensions.clear();
glxExtensions.clear();
eglExtensions.clear();
s_glxExtensions.clear();
s_eglExtensions.clear();
glVersion = 0;
glXVersion = 0;
@ -178,7 +178,22 @@ bool hasEGLVersion(int major, int minor, int release)
bool hasGLExtension(const QByteArray &extension)
{
return glExtensions.contains(extension) || glxExtensions.contains(extension) || eglExtensions.contains(extension);
return glExtensions.contains(extension) || s_glxExtensions.contains(extension) || s_eglExtensions.contains(extension);
}
QList<QByteArray> eglExtensions()
{
return s_eglExtensions;
}
QList<QByteArray> glxExtensions()
{
return s_glxExtensions;
}
QList<QByteArray> openGLExtensions()
{
return glExtensions;
}
static QString formatGLError(GLenum err)

View File

@ -84,6 +84,10 @@ inline bool KWINGLUTILS_EXPORT isPowerOfTwo(int x)
// TODO: Drop for Plasma 6, no longer needed after OpenGL 2.0
int KWINGLUTILS_EXPORT nearestPowerOfTwo(int x);
QList<QByteArray> KWINGLUTILS_EXPORT eglExtensions();
QList<QByteArray> KWINGLUTILS_EXPORT glxExtensions();
QList<QByteArray> KWINGLUTILS_EXPORT openGLExtensions();
class KWINGLUTILS_EXPORT GLShader
{
public: