kwin/plugins/platforms/x11/standalone
Erik Kurzinger 22a441e071 [platforms/x11] Force glXSwapBuffers to block with NVIDIA driver
Summary:
The NVIDIA implementation of glXSwapBuffers will, by default, queue up
to two frames for presentation before blocking. KWin's compositor,
however, assumes that calls to glXSwapBuffers will always block until
the next vblank when rendering double buffered. This assumption isn't
valid, as glXSwapBuffers is specified as being an implicit glFlush,
not an implicit glFinish, and so it isn't required to block. When this
assumption is violated, KWin's frame timing logic will
break. Specifically, there will be extraneous calls to
setCompositeTimer with a waitTime of 0 after the non-blocking buffer
swaps, dramatically reducing desktop responsiveness. To remedy this,
a call to glXWaitGL was added by Thomas Luebking after glXSwapBuffers
in 2015 (see bug 346275, commit
8bea96d701). That glXWaitGL call is
equivalent to a glFinish call in direct rendering, so it was a good
way to make glXSwapBuffers behave as though it implied a glFinish
call.

However, the NVIDIA driver will by default do a busy wait in glFinish,
for reduced latency. Therefore that change dramatically increased CPU
usage. GL_YIELD can be set to USLEEP (case insensitive) to change
the behavior and use usleep instead. When using the NVIDIA driver,
KWin will disable vsync entirely if GL_YIELD isn't set to USLEEP
(case sensitive, a bug in KWin).

However, the NVIDIA driver supports another environment variable,
__GL_MaxFramesAllowed, which can be used to control how many frames
may be queued by glXSwapBuffers. If this is set to 1 the function
will always block until retrace, in line with KWin's expectations.
This allows the now-unnecessary call to glXWaitGL to be removed along
with the logic to conditionally disable vsync, providing a better
experience on NVIDIA hardware.

Reviewers: #kwin, davidedmundson, zzag

Reviewed By: #kwin, davidedmundson, zzag

Subscribers: kwin, davidedmundson, zzag

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19867
2019-03-20 09:56:05 -07:00
..
CMakeLists.txt Build platform plugins in correct sub directory of build dir 2018-12-13 19:36:28 +01:00
edge.cpp
edge.h
effects_mouse_interception_x11_filter.cpp
effects_mouse_interception_x11_filter.h
effects_x11.cpp [platforms/x11] Properly unload effects on X11 2019-03-11 09:23:24 +02:00
effects_x11.h [platforms/x11] Properly unload effects on X11 2019-03-11 09:23:24 +02:00
glx_context_attribute_builder.cpp
glx_context_attribute_builder.h
glxbackend.cpp [platforms/x11] Force glXSwapBuffers to block with NVIDIA driver 2019-03-20 09:56:05 -07:00
glxbackend.h
logging.cpp
logging.h
non_composited_outline.cpp
non_composited_outline.h
overlaywindow_x11.cpp
overlaywindow_x11.h
screenedges_filter.cpp
screenedges_filter.h
screens_xrandr.cpp
screens_xrandr.h
sync_filter.cpp
sync_filter.h
windowselector.cpp
windowselector.h Fix minor EBN issues 2018-08-29 21:02:16 +03:00
x11.json SVN_SILENT made messages (.desktop file) - always resolve ours 2018-10-24 08:42:22 +02:00
x11_decoration_renderer.cpp
x11_decoration_renderer.h
x11_platform.cpp [platforms/x11/standalone] Pass kxkbconfig to Xkb prior to reconfigure 2019-01-05 08:57:29 +01:00
x11_platform.h Fix minor EBN issues 2018-08-29 21:02:16 +03:00
x11cursor.cpp Set specific edge cursor shape when resizing 2018-06-11 10:05:07 +01:00
x11cursor.h Overhaul doxygen comments 2019-02-12 19:29:33 +02:00
xfixes_cursor_event_filter.cpp
xfixes_cursor_event_filter.h
xinputintegration.cpp Add touch support to x11 windowed platform 2018-12-31 07:57:09 +01:00
xinputintegration.h