Add support for GLX_EXT_buffer_age and EGL_EXT_buffer_age

Review Request #114162 - Created Nov. 27, 2013 and submitted

Fredrik Höglund
graesslin, knechtges, luebking, ralfjung
This review request differs from the previous ones in the following ways:

* Both the EGL and the GLX extensions are supported.
* The damage history is managed from begin/endRenderingFrame().
* The effects of occlusion culling is taken into account.
* No assumptions are made about the buffer age value returned from the GL.
* No attempt is made to combine this with other tearing prevention strategies;
  If the extension is supported it will be used unconditionally, and
  the tearing prevention settings are ignored.

I have added many detailed comments in the code that I hope will
make it easy to review.

Since this represents a significant improvement for many users in terms
of increased performance, no tearing, and reduced power consumption,
I'd like to push this to the stable branch shortly after 4.11.4 is tagged.

This is also available as a branch in my kde-workspace clone:

commit 603984278927ec8bef1a56e5c9efd7c6600042c5
Author: Fredrik Höglund <>
Date:   Thu Nov 21 10:44:06 2013 +0100

    kwin: Add support for EXT_buffer_age
    This patch adds support for GLX_EXT_buffer_age, and
    EGL_EXT_buffer_age on X11.

commit 7f47327d9831886bf488135fa2a612e676799625
Author: Fredrik Höglund <>
Date:   Sat Nov 23 15:08:17 2013 +0100

    kwin: Return the modified damage in a separate paintScreen() parameter

commit 68f4275777e5884fa6096f4458f1f156e79f01dd
Author: Fredrik Höglund <>
Date:   Thu Nov 21 10:39:29 2013 +0100

    kwin: Prepare the backend interface for EXT_buffer_age
    Allow prepareRenderingFrame() to return a region that will be
    repainted in addition to the damaged region.
    Pass both the damaged region and the repainted region, which
    may be larger, as parameters to endRenderingFrame().

commit bf77ebeb3ce150da319c1eddca642086c0d850aa
Author: Fredrik Höglund <>
Date:   Thu Nov 21 10:38:16 2013 +0100

    kwin: Don't call glFlush() unnecessarily in endRenderingFrame()
    We should only call glFlush() here if we're deferring the posting
    of the back buffer to the next prepareRenderingFrame() call.

Martin Flöser
Philipp Knechtges
Fredrik Höglund
Fredrik Höglund
Review request changed

Status: Closed (submitted)

Martin Flöser
thanks for pushing! I'm going to do the merge to master later today. Should we inform the release team to include a note in the next release announcment? I'm unsure about it - on the one hand I think a major optimization should be announced on the other hand I fear of it causing some buzz...