vblank_pending is currently a bool, which is reset on every vblank
requests (i.e. sprite pageflip). This can occur more than once per
frame, so turn it into a callback, so we only fire frame-done when we've
collected all the events.

Signed-off-by: Daniel Stone <dani...@collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D1418
---
 libweston/compositor-drm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 0d3ca35..382c8e2 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -836,7 +836,7 @@ drm_output_repaint(struct weston_output *output_base,
                s->fb_last = s->fb_current;
                s->fb_current = s->fb_pending;
                s->fb_pending = NULL;
-               output->vblank_pending = 1;
+               output->vblank_pending++;
        }
 
        return 0;
@@ -944,13 +944,14 @@ vblank_handler(int fd, unsigned int frame, unsigned int 
sec, unsigned int usec,
                         WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
 
        drm_output_update_msc(output, frame);
-       output->vblank_pending = 0;
+       output->vblank_pending--;
+       assert(output->vblank_pending >= 0);
 
        assert(s->fb_last || s->fb_current);
        drm_fb_unref(s->fb_last);
        s->fb_last = NULL;
 
-       if (!output->page_flip_pending) {
+       if (!output->page_flip_pending && !output->vblank_pending) {
                ts.tv_sec = sec;
                ts.tv_nsec = usec * 1000;
                weston_output_finish_frame(&output->base, &ts, flags);
-- 
2.9.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to