[kwin] Drop testapp for detecting whether direct rendering works on glx
The main purpose of the opengl testapp was to set the environment variable LIBGL_ALWAYS_INDIRECT if direct rendering is not supported before glx gets initialized. With Qt5 we may no longer set this environment variable. QtQuick requires direct rendering. On IvyBridge QtQuick is crashing if the variable is set. Thus we are no longer allowed to set it and thus the complete test becomes pointless. The test app basically whitelisted most drivers anyway, the only drivers which were problematic are the proprietary Catalyst drivers. It that's still a problem we can also disable OpenGL compositing on those drivers through the recommendation in the GLPlatform. This also means that the KWIN_DIRECT_GL variable is no longer useful.icc-effect-5.14.5
parent
59e3d0e099
commit
324aae916a
|
@ -331,7 +331,6 @@ if(KWIN_BUILD_OPENGL)
|
|||
if( KWIN_BUILD_OPENGL_1_COMPOSITING )
|
||||
set_target_properties(kdeinit_kwin PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL_1)
|
||||
endif()
|
||||
add_subdirectory(opengltest)
|
||||
target_link_libraries(kdeinit_kwin kwinglutils ${OPENGL_gl_LIBRARY})
|
||||
# -ldl used by OpenGL code
|
||||
find_library(DL_LIBRARY dl)
|
||||
|
|
|
@ -143,19 +143,8 @@ void Compositor::setup()
|
|||
m_starting = true;
|
||||
|
||||
if (!options->isCompositingInitialized()) {
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
// options->reloadCompositingSettings(true) initializes the CompositingPrefs which calls an
|
||||
// external program in turn
|
||||
// run this in an external thread to make startup faster.
|
||||
QFutureWatcher<void> *compositingPrefsFuture = new QFutureWatcher<void>();
|
||||
connect(compositingPrefsFuture, SIGNAL(finished()), this, SLOT(slotCompositingOptionsInitialized()));
|
||||
connect(compositingPrefsFuture, SIGNAL(finished()), compositingPrefsFuture, SLOT(deleteLater()));
|
||||
compositingPrefsFuture->setFuture(QtConcurrent::run(options, &Options::reloadCompositingSettings, true));
|
||||
#else
|
||||
// OpenGL ES does not call the external program, so no need to create a thread
|
||||
options->reloadCompositingSettings(true);
|
||||
slotCompositingOptionsInitialized();
|
||||
#endif
|
||||
} else {
|
||||
slotCompositingOptionsInitialized();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ extern int screen_number; // main.cpp
|
|||
extern bool is_multihead;
|
||||
|
||||
CompositingPrefs::CompositingPrefs()
|
||||
: mEnableDirectRendering(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -128,37 +127,5 @@ bool CompositingPrefs::hasGlx()
|
|||
return s_hasGlx;
|
||||
}
|
||||
|
||||
void CompositingPrefs::detect()
|
||||
{
|
||||
if (!compositingPossible() || openGlIsBroken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
// HACK: This is needed for AIGLX
|
||||
const bool forceIndirect = qstrcmp(qgetenv("LIBGL_ALWAYS_INDIRECT"), "1") == 0;
|
||||
const bool forceEgl = qstrcmp(qgetenv("KWIN_OPENGL_INTERFACE"), "egl") == 0 ||
|
||||
qstrcmp(qgetenv("KWIN_OPENGL_INTERFACE"), "egl_wayland") == 0;
|
||||
if (!forceIndirect && !forceEgl && qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") != 0) {
|
||||
// Start an external helper program that initializes GLX and returns
|
||||
// 0 if we can use direct rendering, and 1 otherwise.
|
||||
// The reason we have to use an external program is that after GLX
|
||||
// has been initialized, it's too late to set the LIBGL_ALWAYS_INDIRECT
|
||||
// environment variable.
|
||||
// Direct rendering is preferred, since not all OpenGL extensions are
|
||||
// available with indirect rendering.
|
||||
const QString opengl_test = QStandardPaths::findExecutable(QStringLiteral("kwin_opengl_test"));
|
||||
if (QProcess::execute(opengl_test) != 0) {
|
||||
mEnableDirectRendering = false;
|
||||
setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
|
||||
} else {
|
||||
mEnableDirectRendering = true;
|
||||
}
|
||||
} else {
|
||||
mEnableDirectRendering = !forceIndirect;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -50,14 +50,6 @@ public:
|
|||
* @returns @c true if GLX is available, @c false otherwise and if not build with OpenGL support.
|
||||
**/
|
||||
static bool hasGlx();
|
||||
bool enableDirectRendering() const {
|
||||
return mEnableDirectRendering;
|
||||
}
|
||||
|
||||
void detect();
|
||||
|
||||
private:
|
||||
bool mEnableDirectRendering;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void GlxBackend::init()
|
|||
|
||||
bool GlxBackend::initRenderingContext()
|
||||
{
|
||||
bool direct = options->isGlDirect();
|
||||
const bool direct = true;
|
||||
|
||||
// Use glXCreateContextAttribsARB() when it's available
|
||||
if (glXCreateContextAttribsARB) {
|
||||
|
|
4
main.cpp
4
main.cpp
|
@ -510,10 +510,6 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
|
|||
KGlobal::locale()->insertCatalog("kwin_scripting");
|
||||
#endif
|
||||
|
||||
// Announce when KWIN_DIRECT_GL is set for above HACK
|
||||
if (qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") == 0)
|
||||
qDebug() << "KWIN_DIRECT_GL set, not forcing LIBGL_ALWAYS_INDIRECT=1";
|
||||
|
||||
QString appname;
|
||||
if (KWin::screen_number == 0)
|
||||
appname = QStringLiteral("org.kde.kwin");
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
########### next target ###############
|
||||
|
||||
set(kwin_opengl_test_SRCS opengltest.cpp )
|
||||
|
||||
kde4_add_executable(kwin_opengl_test ${kwin_opengl_test_SRCS})
|
||||
|
||||
target_link_libraries(kwin_opengl_test ${X11_LIBRARIES} ${OPENGL_gl_LIBRARY})
|
||||
|
||||
install(TARGETS kwin_opengl_test DESTINATION ${LIBEXEC_INSTALL_DIR} )
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2010 Fredrik Höglund <fredrik@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Command to get Catalyst release version string
|
||||
// The output is similar as "String: 9.00-120629n-045581E-ATI"
|
||||
#define SHELL_COMMAND "aticonfig --get-pcs-key=LDC,ReleaseVersion"
|
||||
|
||||
static bool getCatalystVersion(int *first, int *second)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
fp = popen(SHELL_COMMAND, "r");
|
||||
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
fscanf(fp, "String: %d.%d", first, second);
|
||||
|
||||
if (pclose(fp) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return 0 if we can use a direct context, 1 otherwise
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Display *dpy = XOpenDisplay(0);
|
||||
|
||||
int error_base, event_base;
|
||||
if (!glXQueryExtension(dpy, &error_base, &event_base))
|
||||
return 1;
|
||||
|
||||
int major, minor;
|
||||
if (!glXQueryVersion(dpy, &major, &minor))
|
||||
return 1;
|
||||
|
||||
int attribs[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
None,
|
||||
None
|
||||
};
|
||||
|
||||
// Try to find an RGBA visual
|
||||
XVisualInfo *xvi = glXChooseVisual(dpy, DefaultScreen(dpy), attribs);
|
||||
if (!xvi) {
|
||||
// Try again for a doubled buffered visual
|
||||
attribs[sizeof(attribs) / sizeof(int) - 2] = GLX_DOUBLEBUFFER;
|
||||
xvi = glXChooseVisual(dpy, DefaultScreen(dpy), attribs);
|
||||
}
|
||||
|
||||
if (!xvi)
|
||||
return 1;
|
||||
|
||||
// Create a direct rendering context
|
||||
GLXContext ctx = glXCreateContext(dpy, xvi, NULL, True);
|
||||
if (!glXIsDirect(dpy, ctx))
|
||||
return 1;
|
||||
|
||||
// Create a window using the visual.
|
||||
// We only need it to make the context current
|
||||
XSetWindowAttributes attr;
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), xvi->visual, AllocNone);
|
||||
Window win = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 0,
|
||||
xvi->depth, InputOutput, xvi->visual,
|
||||
CWBackPixel | CWBorderPixel | CWColormap, &attr);
|
||||
|
||||
// Try to make the context current
|
||||
if (!glXMakeCurrent(dpy, win, ctx))
|
||||
return 1;
|
||||
|
||||
// glXCreatePixmap() is a GLX 1.3+ function, but it's also provided by EXT_texture_from_pixmap
|
||||
const char *glxExtensions = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
|
||||
if ((major == 1 && minor < 3) && !strstr(glxExtensions, "GLX_EXT_texture_from_pixmap"))
|
||||
return 1;
|
||||
|
||||
// Assume that all Mesa drivers support direct rendering
|
||||
const GLubyte *version = glGetString(GL_VERSION);
|
||||
if (strstr((const char *)version, "Mesa"))
|
||||
return 0;
|
||||
|
||||
// Direct contexts also work with the NVidia driver
|
||||
const GLubyte *vendor = glGetString(GL_VENDOR);
|
||||
if (strstr((const char *)vendor, "NVIDIA"))
|
||||
return 0;
|
||||
|
||||
// Enable direct rendering for AMD Catalyst driver 8.973/8.98 and later. There are
|
||||
// three kinds of Catalyst releases, major, minor and point releses. For example,
|
||||
// 8.98 is one major release, 8.981 is one minor release based on 8.98, and 8.981.1
|
||||
// is one point release based on 8.981, 8.98.1 is one point release based on 8.98
|
||||
if (strstr((const char *)vendor, "ATI") || strstr((const char *)vendor, "AMD")) {
|
||||
int first = 0, second = 0;
|
||||
if (getCatalystVersion(&first, &second))
|
||||
if ((first > 8) || // 9.xx and future releases
|
||||
((first == 8) && (second >= 98) && (second < 100)) || // 8.xx and 8.xx.z
|
||||
((first == 8) && (second >= 973))) //8.xxy and 8.xxy.z
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Direct context also works with VirtualBox's driver
|
||||
const GLubyte *renderer = glGetString(GL_RENDERER);
|
||||
if (strstr((const char *)vendor, "Humper") && strstr((const char *)renderer, "Chromium"))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
16
options.cpp
16
options.cpp
|
@ -143,7 +143,6 @@ Options::Options(QObject *parent)
|
|||
, m_maxFpsInterval(Options::defaultMaxFpsInterval())
|
||||
, m_refreshRate(Options::defaultRefreshRate())
|
||||
, m_vBlankTime(Options::defaultVBlankTime())
|
||||
, m_glDirect(Options::defaultGlDirect())
|
||||
, m_glStrictBinding(Options::defaultGlStrictBinding())
|
||||
, m_glStrictBindingFollowsDriver(Options::defaultGlStrictBindingFollowsDriver())
|
||||
, m_glLegacy(Options::defaultGlLegacy())
|
||||
|
@ -709,15 +708,6 @@ void Options::setVBlankTime(qint64 vBlankTime)
|
|||
emit vBlankTimeChanged();
|
||||
}
|
||||
|
||||
void Options::setGlDirect(bool glDirect)
|
||||
{
|
||||
if (m_glDirect == glDirect) {
|
||||
return;
|
||||
}
|
||||
m_glDirect = glDirect;
|
||||
emit glDirectChanged();
|
||||
}
|
||||
|
||||
void Options::setGlStrictBinding(bool glStrictBinding)
|
||||
{
|
||||
if (m_glStrictBinding == glStrictBinding) {
|
||||
|
@ -938,14 +928,8 @@ void Options::reloadCompositingSettings(bool force)
|
|||
setCompositingInitialized(true);
|
||||
|
||||
// Compositing settings
|
||||
CompositingPrefs prefs;
|
||||
if (compositingMode() == OpenGLCompositing) {
|
||||
prefs.detect();
|
||||
}
|
||||
|
||||
KConfigGroup config(m_settings->config(), "Compositing");
|
||||
|
||||
setGlDirect(prefs.enableDirectRendering());
|
||||
setGlSmoothScale(qBound(-1, config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), 2));
|
||||
setGlStrictBindingFollowsDriver(!config.hasKey("GLStrictBinding"));
|
||||
if (!isGlStrictBindingFollowsDriver()) {
|
||||
|
|
|
@ -179,7 +179,6 @@ class Options : public KDecorationOptions
|
|||
Q_PROPERTY(qint64 maxFpsInterval READ maxFpsInterval WRITE setMaxFpsInterval NOTIFY maxFpsIntervalChanged)
|
||||
Q_PROPERTY(uint refreshRate READ refreshRate WRITE setRefreshRate NOTIFY refreshRateChanged)
|
||||
Q_PROPERTY(qint64 vBlankTime READ vBlankTime WRITE setVBlankTime NOTIFY vBlankTimeChanged)
|
||||
Q_PROPERTY(bool glDirect READ isGlDirect WRITE setGlDirect NOTIFY glDirectChanged)
|
||||
Q_PROPERTY(bool glStrictBinding READ isGlStrictBinding WRITE setGlStrictBinding NOTIFY glStrictBindingChanged)
|
||||
/**
|
||||
* Whether strict binding follows the driver or has been overwritten by a user defined config value.
|
||||
|
@ -535,9 +534,6 @@ public:
|
|||
qint64 vBlankTime() const {
|
||||
return m_vBlankTime;
|
||||
}
|
||||
bool isGlDirect() const {
|
||||
return m_glDirect;
|
||||
}
|
||||
bool isGlStrictBinding() const {
|
||||
return m_glStrictBinding;
|
||||
}
|
||||
|
@ -611,7 +607,6 @@ public:
|
|||
void setMaxFpsInterval(qint64 maxFpsInterval);
|
||||
void setRefreshRate(uint refreshRate);
|
||||
void setVBlankTime(qint64 vBlankTime);
|
||||
void setGlDirect(bool glDirect);
|
||||
void setGlStrictBinding(bool glStrictBinding);
|
||||
void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver);
|
||||
void setGlLegacy(bool glLegacy);
|
||||
|
@ -800,7 +795,6 @@ Q_SIGNALS:
|
|||
void maxFpsIntervalChanged();
|
||||
void refreshRateChanged();
|
||||
void vBlankTimeChanged();
|
||||
void glDirectChanged();
|
||||
void glStrictBindingChanged();
|
||||
void glStrictBindingFollowsDriverChanged();
|
||||
void glLegacyChanged();
|
||||
|
@ -850,7 +844,6 @@ private:
|
|||
// Settings that should be auto-detected
|
||||
uint m_refreshRate;
|
||||
qint64 m_vBlankTime;
|
||||
bool m_glDirect;
|
||||
bool m_glStrictBinding;
|
||||
bool m_glStrictBindingFollowsDriver;
|
||||
bool m_glLegacy;
|
||||
|
|
Loading…
Reference in New Issue