From 5213c4aff6586cd05658e693606797cbbab55dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 26 Jul 2011 07:55:20 +0200 Subject: [PATCH] Drop direct rendering setting The advanced compositing option "direct rendering" could only correctly be honored in the case of proprietary NVIDIA drivers. In all other cases playing with the setting was most likely harmful as it could result in inconsistent states and the option not to be honored at all. This patch resolves this issue by moving the detection whether to use a direct rendering context completely into the hands of the set environment variables or the helper program: * if LIBGL_ALWAYS_INDIRECT is set, we use an indirect context * if KWIN_DIRECT_GL is set, we use a direct context * if none of the two are set, we use the helper program, if it returns 0 we create a direct context, otherwise we set LIBGL_ALWAYS_INDIRECT and create an indirect context If a user really wants to influence the behavior the environment variables can be used. REVIEW: 102074 --- compositingprefs.cpp | 11 +++++++++-- kcmkwin/kwincompositing/main.cpp | 6 ------ kcmkwin/kwincompositing/main.ui | 14 ++------------ options.cpp | 2 +- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/compositingprefs.cpp b/compositingprefs.cpp index cf3bc1436b..a6d354a891 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -192,7 +192,8 @@ void CompositingPrefs::detect() } #else // HACK: This is needed for AIGLX - if (qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") != 0) { + const bool forceIndirect = qstrcmp(qgetenv("LIBGL_ALWAYS_INDIRECT"), "1") == 0; + if (!forceIndirect && 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 @@ -201,8 +202,14 @@ void CompositingPrefs::detect() // Direct rendering is preferred, since not all OpenGL extensions are // available with indirect rendering. const QString opengl_test = KStandardDirs::findExe("kwin_opengl_test"); - if (QProcess::execute(opengl_test) != 0) + if (QProcess::execute(opengl_test) != 0) { + mEnableDirectRendering = false; setenv("LIBGL_ALWAYS_INDIRECT", "1", true); + } else { + mEnableDirectRendering = true; + } + } else { + mEnableDirectRendering = !forceIndirect; } if (!hasGlx()) { kDebug(1212) << "No GLX available"; diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index f39ace1730..02d9957744 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -123,7 +123,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList connect(ui.glScaleFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(ui.xrScaleFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.glShaders, SIGNAL(toggled(bool)), this, SLOT(changed())); @@ -395,7 +394,6 @@ void KWinCompositingConfig::loadAdvancedTab() ui.xrScaleFilter->setCurrentIndex((int)config.readEntry("XRenderSmoothScale", false)); ui.glScaleFilter->setCurrentIndex(config.readEntry("GLTextureFilter", 2)); - ui.glDirect->setChecked(config.readEntry("GLDirect", mDefaultPrefs.enableDirectRendering())); ui.glVSync->setChecked(config.readEntry("GLVSync", mDefaultPrefs.enableVSync())); ui.glShaders->setChecked(!config.readEntry("GLLegacy", false)); @@ -551,8 +549,6 @@ bool KWinCompositingConfig::saveAdvancedTab() if (config.readEntry("Backend", "OpenGL") != ((ui.compositingType->currentIndex() == OPENGL_INDEX) ? "OpenGL" : "XRender") - || config.readEntry("GLDirect", mDefaultPrefs.enableDirectRendering()) - != ui.glDirect->isChecked() || config.readEntry("GLVSync", mDefaultPrefs.enableVSync()) != ui.glVSync->isChecked() || config.readEntry("GLLegacy", false) == ui.glShaders->isChecked()) { m_showConfirmDialog = true; @@ -569,7 +565,6 @@ bool KWinCompositingConfig::saveAdvancedTab() config.writeEntry("XRenderSmoothScale", ui.xrScaleFilter->currentIndex() == 1); config.writeEntry("GLTextureFilter", ui.glScaleFilter->currentIndex()); - config.writeEntry("GLDirect", ui.glDirect->isChecked()); config.writeEntry("GLVSync", ui.glVSync->isChecked()); config.writeEntry("GLLegacy", !ui.glShaders->isChecked()); @@ -721,7 +716,6 @@ void KWinCompositingConfig::defaults() ui.unredirectFullscreen->setChecked(false); ui.xrScaleFilter->setCurrentIndex(0); ui.glScaleFilter->setCurrentIndex(2); - ui.glDirect->setChecked(mDefaultPrefs.enableDirectRendering()); ui.glVSync->setChecked(mDefaultPrefs.enableVSync()); ui.glShaders->setChecked(true); } diff --git a/kcmkwin/kwincompositing/main.ui b/kcmkwin/kwincompositing/main.ui index ed3da09314..4954ceff5c 100644 --- a/kcmkwin/kwincompositing/main.ui +++ b/kcmkwin/kwincompositing/main.ui @@ -771,17 +771,7 @@ p, li { white-space: pre-wrap; } true - - - - Enable direct rendering - - - false - - - - + Use VSync @@ -791,7 +781,7 @@ p, li { white-space: pre-wrap; } - + If enabled all rendering will be performed with Shaders written in the OpenGL Shading Language. diff --git a/options.cpp b/options.cpp index 09a3163e27..8cd8a87ab5 100644 --- a/options.cpp +++ b/options.cpp @@ -320,7 +320,7 @@ void Options::reloadCompositingSettings(bool force) prefs.detect(); useCompositing = config.readEntry("Enabled" , prefs.recommendCompositing()); - glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering()); + glDirect = prefs.enableDirectRendering(); glVSync = config.readEntry("GLVSync", prefs.enableVSync()); glSmoothScale = qBound(-1, config.readEntry("GLTextureFilter", 2), 2); glStrictBinding = config.readEntry("GLStrictBinding", prefs.strictBinding());