wlr_scene: Debounce dmabuf feedback on scanout

Direct scanout can be enabled and disabled on a frame-by-frame basis,
and so we could end up sending different feedback to a surface on every
other frame. Reacting to new feedback is expensive, as the client may
need to reallocate their swapchain.

Debounce the state change a number of frames, for now set to 30, to
avoid immediate reaction to scanout (or composition) that only lasts a
few frames.

A timer could be used instead, but it did not seem worth the complexity.
What just want to know that the state has been stable across a
reasonable number of samples, and a counter seems sufficient for that.
This commit is contained in:
Kenny Levinsen 2025-03-30 19:06:42 +02:00 committed by Simon Ser
parent 792bee9657
commit c450991c4b
2 changed files with 63 additions and 21 deletions

View file

@ -227,6 +227,14 @@ struct wlr_scene_output {
pixman_region32_t pending_commit_damage;
uint8_t index;
/**
* When scanout is applicable, we increment this every time a frame is rendered until
* DMABUF_FEEDBACK_DEBOUNCE_FRAMES is hit to debounce the scanout dmabuf feedback. Likewise,
* when scanout is no longer applicable, we decrement this until zero is hit to debounce
* composition dmabuf feedback.
*/
uint8_t dmabuf_feedback_debounce;
bool prev_scanout;
bool gamma_lut_changed;