This helper monitors buffers for implicit and explicit work
synchronization, delaying the surface commit until the fences are ready
to be consumed for synchronization (i.e., fences have materialized), or
for the work to be complete, depending on the specified waiter mode.
Through this, the compositor can avoid stalling on incomplete work,
staying fully interactive until the buffer is ready to be sampled.
This is a generalization of Simon's patch that added a waiter for
traditional implicit sync.
Based-on-patch-by: Simon Ser <contact@emersion.fr>
The old approach of using a signal is fundamentally broken for a common
usecase: When the waiter is ready, it's common to immediately finish and
free any resources associated with it.
Because of the semantics of wl_signal_emit_mutable() this is UB.
wl_signal_emit_mutable() always excepts that the waiter hasn't been freed
until the signal has finished being emitted.
Instead of over engineering the solution, let's just add a callback required
by wlr_drm_syncobj_timeline_waiter_init(). In this callback, the implementation
is free to finish() or free() any resource it likes.