Support EGL_KHR_partial_update for performance
Weston's gl-renderer currently uses
EGL_EXT_buffer_age to determine the 'age' of the back buffer it's currently rendering into, to enable partial renders. It would be great if we could use
EGL_KHR_partial_update where possible instead, as it's much more efficient.
When gl-renderer repaints an output, we know the 'damage' (changed / needs-repaint) region of that output. If we only repaint the damaged area, we save the workload of painting something which has already changed. The 'buffer age' extension enables this: it tells us how 'old' (in number of
eglSwapBuffers calls) our current GLES buffer is. If the buffer is, say, two frames old, then we know in order to make it current, we must paint the current damaged area, as well as the damage area from the previous frame as well. This can be a very useful performance optimisation when only changing small areas.
Turning on the triangle-fan debug mode can show this in action, and demonstrate just how little of the screen we repaint.
Whilst this mode is good for immediate-rendering GPUs, it's less good for tiled-mode GPUs, as found in mobile devices. Whilst IMR architectures typically render directly to the buffer in memory, tilers first have to load the old data into a tile buffer, render into another part of the tile buffer, then flush the tile buffer back to main memory. This can sometimes result in unnecessarily loading the entire old buffer back into memory first, making it slower than we would have without the performance optimisation. A real-life example can be found at lima/mesa#59.
EGL_KHR_partial_update solves this by making the communication between Weston and the EGL driver two-way. Weston still queries for the buffer age, but it then also feeds its intended damage area into EGL with
eglSetDamageRegionKHR. As the driver knows which regions will be changed and which regions will be preserved, it can avoid loading old buffer content into memory if that content is going to be overwritten, preserving our optimisation.
buffer_age would be useful and a very good first patch for someone looking to get into Weston.