platforms/x11: Always set swap interval to 1
With the new compositing scheduling, we want the screen to be redrawn as close as possible to the next vblank. Furthermore, compositing is no longer driven by a timer. This change removes the NoSwapEncourage swap strategy as it doesn't make sense now, in addition to that it just does not work on Wayland.
This commit is contained in:
parent
2e3a6b7253
commit
6d20d19fec
10 changed files with 35 additions and 32 deletions
|
@ -227,11 +227,6 @@ Alternatively, you might want to use the XRender backend instead.</string>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1">
|
<item row="12" column="1">
|
||||||
<widget class="QComboBox" name="kcfg_glPreferBufferSwap">
|
<widget class="QComboBox" name="kcfg_glPreferBufferSwap">
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Never</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Automatic</string>
|
<string>Automatic</string>
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
<entry name="glPreferBufferSwap" key="GLPreferBufferSwap" type="Enum">
|
<entry name="glPreferBufferSwap" key="GLPreferBufferSwap" type="Enum">
|
||||||
<default>AutoSwapStrategy</default>
|
<default>AutoSwapStrategy</default>
|
||||||
<choices>
|
<choices>
|
||||||
<choice name="NoSwapEncourage" value="n" />
|
|
||||||
<choice name="AutoSwapStrategy" value="a" />
|
<choice name="AutoSwapStrategy" value="a" />
|
||||||
<choice name="ExtendDamage" value="e" />
|
<choice name="ExtendDamage" value="e" />
|
||||||
<choice name="PaintFullScreen" value="p" />
|
<choice name="PaintFullScreen" value="p" />
|
||||||
|
|
|
@ -130,15 +130,15 @@ void KWinCompositingKCM::init()
|
||||||
// tearing prevention
|
// tearing prevention
|
||||||
connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this,
|
connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this,
|
||||||
[this](int index) {
|
[this](int index) {
|
||||||
if (index == 2) {
|
if (index == 1) {
|
||||||
// only when cheap - tearing
|
// only when cheap - tearing
|
||||||
m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video."));
|
m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video."));
|
||||||
m_form.tearingWarning->animatedShow();
|
m_form.tearingWarning->animatedShow();
|
||||||
} else if (index == 3) {
|
} else if (index == 2) {
|
||||||
// full screen repaints
|
// full screen repaints
|
||||||
m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems."));
|
m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems."));
|
||||||
m_form.tearingWarning->animatedShow();
|
m_form.tearingWarning->animatedShow();
|
||||||
} else if (index == 4) {
|
} else if (index == 3) {
|
||||||
// re-use screen content
|
// re-use screen content
|
||||||
m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers."));
|
m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers."));
|
||||||
m_form.tearingWarning->animatedShow();
|
m_form.tearingWarning->animatedShow();
|
||||||
|
|
|
@ -6,6 +6,8 @@ install(PROGRAMS kwin-5.18-move-animspeed.py
|
||||||
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
||||||
install(PROGRAMS kwin-5.21-desktop-grid-click-behavior.py
|
install(PROGRAMS kwin-5.21-desktop-grid-click-behavior.py
|
||||||
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
||||||
|
install(PROGRAMS kwin-5.21-no-swap-encourage.py
|
||||||
|
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
||||||
|
|
||||||
install(FILES kwinrules.upd
|
install(FILES kwinrules.upd
|
||||||
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
|
||||||
|
|
11
kconf_update/kwin-5.21-no-swap-encourage.py
Normal file
11
kconf_update/kwin-5.21-no-swap-encourage.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import fileinput
|
||||||
|
|
||||||
|
for line in fileinput.input():
|
||||||
|
if not line.startswith("GLPreferBufferSwap="):
|
||||||
|
continue
|
||||||
|
value = line[len("GLPreferBufferSwap="):].strip()
|
||||||
|
if value != "n":
|
||||||
|
continue
|
||||||
|
print("# DELETE GLPreferBufferSwap") # will use the default swap strategy
|
|
@ -43,3 +43,9 @@ Id=desktop-grid-click-behavior
|
||||||
File=kwinrc
|
File=kwinrc
|
||||||
Group=Effect-DesktopGrid
|
Group=Effect-DesktopGrid
|
||||||
Script=kwin-5.21-desktop-grid-click-behavior.py,python3
|
Script=kwin-5.21-desktop-grid-click-behavior.py,python3
|
||||||
|
|
||||||
|
# Remove GLPreferBufferSwap if it has a value of "n"
|
||||||
|
Id=no-swap-encourage
|
||||||
|
File=kwinrc
|
||||||
|
Group=Compositing
|
||||||
|
File=kwin-5.21-no-swap-encourage.py,python3
|
||||||
|
|
|
@ -896,7 +896,7 @@ void Options::reloadCompositingSettings(bool force)
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
c = s.at(0).toLatin1();
|
c = s.at(0).toLatin1();
|
||||||
if (c != 'a' && c != 'c' && c != 'p' && c != 'e')
|
if (c != 'a' && c != 'c' && c != 'p' && c != 'e')
|
||||||
c = 0;
|
c = Options::defaultGlPreferBufferSwap();
|
||||||
setGlPreferBufferSwap(c);
|
setGlPreferBufferSwap(c);
|
||||||
|
|
||||||
m_xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false);
|
m_xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false);
|
||||||
|
|
|
@ -590,7 +590,7 @@ public:
|
||||||
return m_glPlatformInterface;
|
return m_glPlatformInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GlSwapStrategy { NoSwapEncourage = 0, CopyFrontBuffer = 'c', PaintFullScreen = 'p', ExtendDamage = 'e', AutoSwapStrategy = 'a' };
|
enum GlSwapStrategy { CopyFrontBuffer = 'c', PaintFullScreen = 'p', ExtendDamage = 'e', AutoSwapStrategy = 'a' };
|
||||||
Q_ENUM(GlSwapStrategy)
|
Q_ENUM(GlSwapStrategy)
|
||||||
GlSwapStrategy glPreferBufferSwap() const {
|
GlSwapStrategy glPreferBufferSwap() const {
|
||||||
return m_glPreferBufferSwap;
|
return m_glPreferBufferSwap;
|
||||||
|
|
|
@ -102,20 +102,15 @@ void EglOnXBackend::init()
|
||||||
if (surfaceHasSubPost) {
|
if (surfaceHasSubPost) {
|
||||||
qCDebug(KWIN_CORE) << "EGL implementation and surface support eglPostSubBufferNV, let's use it";
|
qCDebug(KWIN_CORE) << "EGL implementation and surface support eglPostSubBufferNV, let's use it";
|
||||||
|
|
||||||
if (options->glPreferBufferSwap() != Options::NoSwapEncourage) {
|
// check if swap interval 1 is supported
|
||||||
// check if swap interval 1 is supported
|
EGLint val;
|
||||||
EGLint val;
|
eglGetConfigAttrib(eglDisplay(), config(), EGL_MAX_SWAP_INTERVAL, &val);
|
||||||
eglGetConfigAttrib(eglDisplay(), config(), EGL_MAX_SWAP_INTERVAL, &val);
|
if (val >= 1) {
|
||||||
if (val >= 1) {
|
if (eglSwapInterval(eglDisplay(), 1)) {
|
||||||
if (eglSwapInterval(eglDisplay(), 1)) {
|
qCDebug(KWIN_CORE) << "Enabled v-sync";
|
||||||
qCDebug(KWIN_CORE) << "Enabled v-sync";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
qCWarning(KWIN_CORE) << "Cannot enable v-sync as max. swap interval is" << val;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// disable v-sync
|
qCWarning(KWIN_CORE) << "Cannot enable v-sync as max. swap interval is" << val;
|
||||||
eglSwapInterval(eglDisplay(), 0);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates.
|
/* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates.
|
||||||
|
|
|
@ -224,17 +224,12 @@ void GlxBackend::init()
|
||||||
m_haveINTELSwapEvent = false;
|
m_haveINTELSwapEvent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool wantSync = options->glPreferBufferSwap() != Options::NoSwapEncourage;
|
if (haveSwapInterval) {
|
||||||
if (wantSync && glXIsDirect(display(), ctx)) {
|
setSwapInterval(1);
|
||||||
if (haveSwapInterval) { // glXSwapInterval is preferred being more reliable
|
|
||||||
setSwapInterval(1);
|
|
||||||
} else {
|
|
||||||
qCWarning(KWIN_X11STANDALONE) << "glSwapInterval is unsupported";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// disable v-sync (if possible)
|
qCWarning(KWIN_X11STANDALONE) << "glSwapInterval is unsupported";
|
||||||
setSwapInterval(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glPlatform->isVirtualBox()) {
|
if (glPlatform->isVirtualBox()) {
|
||||||
// VirtualBox does not support glxQueryDrawable
|
// VirtualBox does not support glxQueryDrawable
|
||||||
// this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension
|
// this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension
|
||||||
|
|
Loading…
Reference in a new issue