This is an early WIP of the GLX backend. I go through that with a chainsaw
at the moment and hope for some feedback by people knowing all the history
about it and stop me before accidentally cutting off the branch we are
sitting on. ;)
Overall goals:
- Make the code less convoluted.
- Sync paint with vblanks if extensions required for that are available
- Reduce delay by pushing paint to end of vblank cycle, see [1].
Currently doing:
- Remove triple buffering. A compositor does not need this when it doesn't screw up in some other way.
- Remove vsync option. Always sync with vblanks.
- Replace GLX_MESA_, GLX_EXT_. and GLX_SGI_swap_control with GLX_OML_sync_control only, since this is the standard nowadays and we don't need to optimize for every legacy X device in the world.
- Remove blocksForRetrace, instead use the Intel swap event or glFinish to sync with vblank.
glFinish should block till vblank, see [2][3].(doesn't seem to be true per se, maybe driver dependent) - In endRenderingFrame don't present a second time. Why was it there in the first place? -> Thanks to @fredrik's comments this is now clear: in beginRenderingFrame it's called if we don't block on retrace and if do block in endRenderingFrame and according to comment because damage gets reset in the later case it would be noop in beginRenderingFrame. Needs to get replaced though to make the code less complex.
Added 19-08-13:
- When swap events are available don't use the fallback timer.
- Delay timer reduces latency between paint and vsync
Added 19-08-20:
- Move present to endRenderingFrame to have less than one frame of latency.
Added 19-08-21:
- For now perform compositing always from event loop. Without it Wayland session crashes. Probably otherwise hidden issue in Effects.
- Cleanup: Remove more plumbing for vsync and retrace blocking and swap-profiler
Open questions:
- Is glFinish really blocking till vblank? X Present extension provides events to get notified about vblank, but since we channel through GLX this is not available directly to my knowledge. So it's kind of weird that there is only the Intel swap event to wrap that behavior explicitly.
- Compositor has a compositing timer. It seems we always wait for it, but if we sync with vblank there is no reason to do it this way. Instead only use is as a fallback in case sync with vblank is not supported?
[1] https://ppaalanen.blogspot.com/2015/02/weston-repaint-scheduling.html
[2] https://www.khronos.org/opengl/wiki/Swap_Interval
[3] https://github.com/tildearrow/kwin-lowlatency#background