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
This commit is contained in:
Martin Gräßlin 2011-07-26 07:55:20 +02:00
parent fb4d148f53
commit 5213c4aff6
4 changed files with 12 additions and 21 deletions

View file

@ -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";

View file

@ -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<bool>("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<bool>("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);
}

View file

@ -771,17 +771,7 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="glDirect">
<property name="text">
<string>Enable direct rendering</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="glVSync">
<property name="text">
<string>Use VSync</string>
@ -791,7 +781,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QCheckBox" name="glShaders">
<property name="toolTip">
<string>If enabled all rendering will be performed with Shaders written in the OpenGL Shading Language.

View file

@ -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());