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.
master
Vlad Zahorodnii 4 years ago
parent 2e3a6b7253
commit 6d20d19fec

@ -227,11 +227,6 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="kcfg_glPreferBufferSwap">
<item>
<property name="text">
<string>Never</string>
</property>
</item>
<item>
<property name="text">
<string>Automatic</string>

@ -45,7 +45,6 @@
<entry name="glPreferBufferSwap" key="GLPreferBufferSwap" type="Enum">
<default>AutoSwapStrategy</default>
<choices>
<choice name="NoSwapEncourage" value="n" />
<choice name="AutoSwapStrategy" value="a" />
<choice name="ExtendDamage" value="e" />
<choice name="PaintFullScreen" value="p" />

@ -130,15 +130,15 @@ void KWinCompositingKCM::init()
// tearing prevention
connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this,
[this](int index) {
if (index == 2) {
if (index == 1) {
// 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->animatedShow();
} else if (index == 3) {
} else if (index == 2) {
// full screen repaints
m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems."));
m_form.tearingWarning->animatedShow();
} else if (index == 4) {
} else if (index == 3) {
// re-use screen content
m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers."));
m_form.tearingWarning->animatedShow();

@ -6,6 +6,8 @@ install(PROGRAMS kwin-5.18-move-animspeed.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kwin-5.21-desktop-grid-click-behavior.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kwin-5.21-no-swap-encourage.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(FILES kwinrules.upd
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})

@ -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
Group=Effect-DesktopGrid
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())
c = s.at(0).toLatin1();
if (c != 'a' && c != 'c' && c != 'p' && c != 'e')
c = 0;
c = Options::defaultGlPreferBufferSwap();
setGlPreferBufferSwap(c);
m_xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false);

@ -590,7 +590,7 @@ public:
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)
GlSwapStrategy glPreferBufferSwap() const {
return m_glPreferBufferSwap;

@ -102,7 +102,6 @@ void EglOnXBackend::init()
if (surfaceHasSubPost) {
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
EGLint val;
eglGetConfigAttrib(eglDisplay(), config(), EGL_MAX_SWAP_INTERVAL, &val);
@ -113,10 +112,6 @@ void EglOnXBackend::init()
} else {
qCWarning(KWIN_CORE) << "Cannot enable v-sync as max. swap interval is" << val;
}
} else {
// disable v-sync
eglSwapInterval(eglDisplay(), 0);
}
} else {
/* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates.
* However, that does not work in EGL - glCopyPixels with glDrawBuffer(GL_FRONT); does nothing.

@ -224,17 +224,12 @@ void GlxBackend::init()
m_haveINTELSwapEvent = false;
}
const bool wantSync = options->glPreferBufferSwap() != Options::NoSwapEncourage;
if (wantSync && glXIsDirect(display(), ctx)) {
if (haveSwapInterval) { // glXSwapInterval is preferred being more reliable
if (haveSwapInterval) {
setSwapInterval(1);
} else {
qCWarning(KWIN_X11STANDALONE) << "glSwapInterval is unsupported";
}
} else {
// disable v-sync (if possible)
setSwapInterval(0);
}
if (glPlatform->isVirtualBox()) {
// VirtualBox does not support glxQueryDrawable
// this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension

Loading…
Cancel
Save