Bug 470497 - Compositor-provided V-Sync is active on fullscreen applications even when turned off in the settings
Summary: Compositor-provided V-Sync is active on fullscreen applications even when tur...
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 5.27.5
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-31 21:31 UTC by Hexagon
Modified: 2023-06-13 21:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Compositor option to disable V-Sync in fullscreen applications (244.73 KB, image/png)
2023-05-31 21:31 UTC, Hexagon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hexagon 2023-05-31 21:31:14 UTC
Created attachment 159376 [details]
Compositor option to disable V-Sync in fullscreen applications

KWin as a Wayland compositor provides V-Sync over all screen content to prevent tearing. As high performance graphics applications like video games often provide their own V-Sync implementation the compositor-provided V-Sync should be disabled to avoid two V-Sync operations in a row and to give the application the option to disable V-Sync alltogether to favor latency over image quality.

To achieve this behavior KWin has a checkbox in the System Settings under "Display and Monitor -> Compositor" called "Reduce latency by allowing screen tearing artifacts in fullscreen applications", so basically "Disable compositor V-Sync in fullscreen applications". Unfortunately this checkbox does nothing, as Nate Graham looked up in the code. Therefore currently applications in KWin Wayland are not able to run without forced V-Sync, which they should be able to.

STEPS TO REPRODUCE
1. Go to the system settings "Display and Monitor -> Compositor" and test with the activated and deactivated check box "Reduce latency by allowing screen tearing artifacts in fullscreen applications"
2. Open different fullscreen applications which do not have internal V-Sync like "glxgears -fullscreen"

OBSERVED RESULT

I can not get fullscreen applications to tear, suggesting that KWin forces V-Sync itself, even if it should not.

EXPECTED RESULT

The applications should tear and KWin should not apply V-Sync leaving them the option to figure it out themselves.

SOFTWARE/OS VERSIONS
Linux: 6.3.4-arch1-1 (64-bit)
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.106.0
Qt Version: 5.15.9
Comment 1 Nate Graham 2023-05-31 21:52:12 UTC
Can confirm. Looks like it actually isn't even wired up to anything internally.
Comment 2 Zamundaaa 2023-06-10 21:59:26 UTC
> KWin as a Wayland compositor provides V-Sync over all screen content to prevent tearing. As high performance graphics applications like video games often provide their own V-Sync implementation the compositor-provided V-Sync should be disabled to avoid two V-Sync operations in a row

That's not how VSync works; applications can't do VSync. It's a driver (and hardware) feature that can be optionally turned off by the compositor, and it can't be stacked or anything like that.


The option *is* wired up in KWin. The problem is the rest of the world... The option only does something if:
- your kernel driver supports it (should be supported with Intel and AMD, at least in most cases)
- you're using the legacy driver API. By default KWin does not use this if the newer atomic API is available, as it has numerous benefits. Tearing support in the atomic API is still a WIP
- you have an application that requests a presentation mode that allows tearing (which right now only Vulkan apps can do, as OpenGL does not have a proper API for this)
- you have the implementation in Mesa for passing this request to the compositor: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18268

For X11 apps, you also need
- the necessary protocol changes that circumvents some unfortunate historical problems of the "normal" tearing API for X11: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/58
- the implementation of that protocol change in Xwayland: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/665
- the implementation of the protocol change in libxcb: https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/merge_requests/38
- the implementation of the protocol change in Mesa: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19125

If you're using NVidia, you also need the matching implementations in their driver, which NVidia will have to provide themselves.

In hindsight, it would've been good to add a disclaimer about the driver side of things next to the checkbox
Comment 3 Nate Graham 2023-06-13 21:16:25 UTC
Sounds kind of like we need to either hide that setting to avoid misleading people, or else accompany it with a paragraph of qualifier text in a ContextualHelpButton. :/