gbm/drm: Pick the oldest available buffer in get_back_bo
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 23 Nov 2016 22:40:42 +0000 (16:40 -0600)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 13 Jan 2017 15:52:11 +0000 (15:52 +0000)
commit4f1d27a406478d405eac6f9894ccc46a80034adb
treeee9eca8806e026c66bcb0c3e6a2e97745c8385b6
parent36b9976e1f99e8070c67cb8a255793939db77d02
gbm/drm: Pick the oldest available buffer in get_back_bo

Applications may query the back buffer age to efficiently perform
partial updates. Generally the application will keep a fixed length
damage history, and use this to calculate what needs to be redrawn
based on the age of the back buffer it's about to render to.

If presented with a buffer that has an age greater than the
length of the damage history, the application will likely have
to completely repaint the buffer.

Our current buffer selection strategy is to pick the first available
buffer without considering its age.  If an application frequently
manages to fit within two buffers but occasionally requires a third,
this extra buffer will almost always be old enough to fall outside
of a reasonably long damage history, and require a full repaint.

This patch changes the buffer selection behaviour to prefer the oldest
available buffer.

By selecting the oldest available buffer, the application will likely
always be able to use its damage history, at a cost of having to
perform slightly more work every frame.  This is an improvement if
the cost of a full repaint is heavy, and the surface damage between
frames is relatively small.

It should be noted that since we don't currently trim our queue in
any way, an application that briefly needs a large number of buffers
will continue to receive older buffers than it would if it only ever
needed two buffers.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
src/egl/drivers/dri2/platform_drm.c