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 [platforms/x11] Fix incorrect screen edge approaching with switch desktop on window move 2017-07-06 19:12:28 +02:00
edge.h [platforms/x11] Fix incorrect screen edge approaching with switch desktop on window move 2017-07-06 19:12:28 +02:00
effects_mouse_interception_x11_filter.cpp Move X11-only specific part of EffectsHandlerImpl to x11 platform plugin 2017-10-16 16:54:17 +02:00
effects_mouse_interception_x11_filter.h Move X11-only specific part of EffectsHandlerImpl to x11 platform plugin 2017-10-16 16:54:17 +02:00
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 [platforms/x11] Use a GlxContextAttributeBuilder 2017-08-19 11:34:51 +02:00
glx_context_attribute_builder.h [platforms/x11] Use a GlxContextAttributeBuilder 2017-08-19 11:34:51 +02:00
glxbackend.cpp [platforms/x11] Force glXSwapBuffers to block with NVIDIA driver 2019-03-20 09:56:05 -07:00
glxbackend.h Move SceneOpenGL into a dedicated plugin 2017-09-30 13:12:10 +02:00
logging.cpp [plugins/platforms] Dedicated logging category for X11 standalone platform 2016-04-12 14:48:54 +02:00
logging.h [plugins/platforms] Dedicated logging category for X11 standalone platform 2016-04-12 14:48:54 +02:00
non_composited_outline.cpp Move NonComposited Outline into the X11 standalone platform 2017-09-01 17:07:23 +02:00
non_composited_outline.h Move NonComposited Outline into the X11 standalone platform 2017-09-01 17:07:23 +02:00
overlaywindow_x11.cpp Move event filtering for overlay window into an X11EventFilter 2017-08-12 11:32:53 +02:00
overlaywindow_x11.h Move event filtering for overlay window into an X11EventFilter 2017-08-12 11:32:53 +02:00
screenedges_filter.cpp Move X11 specific event filtering for ScreenEdges into x11 standalone platform 2017-09-01 17:01:01 +02:00
screenedges_filter.h Move X11 specific event filtering for ScreenEdges into x11 standalone platform 2017-09-01 17:01:01 +02:00
screens_xrandr.cpp Try fixing build failure on CI 2017-09-12 21:20:18 +02:00
screens_xrandr.h Port some displayWidth/displayHeight usages to Screens::size() 2017-09-01 17:11:10 +02:00
sync_filter.cpp Create a dedicated X11Filter for Client sync events and move it to X11 platform 2017-10-19 19:56:58 +02:00
sync_filter.h Create a dedicated X11Filter for Client sync events and move it to X11 platform 2017-10-19 19:56:58 +02:00
windowselector.cpp [x11] Fix interactive point selection 2018-02-05 21:21:27 +01:00
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 Move the X11 Decoration Renderer into the X11 standalone platform 2017-09-01 17:49:32 +02:00
x11_decoration_renderer.h Move the X11 Decoration Renderer into the X11 standalone platform 2017-09-01 17:49:32 +02:00
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 Move XFixes cursor change tracking into the x11 standalone platform 2017-09-30 12:58:17 +02:00
xfixes_cursor_event_filter.h Move XFixes cursor change tracking into the x11 standalone platform 2017-09-30 12:58:17 +02:00
xinputintegration.cpp Add touch support to x11 windowed platform 2018-12-31 07:57:09 +01:00
xinputintegration.h Split modifier only handling into a dedicated InputEventSpy 2017-02-14 17:02:18 +01:00