summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2016-11-04 16:17:39 +0000
committerDaniel Stone <daniels@collabora.com>2017-02-07 19:16:31 +0000
commite98ce75b77c646cd64e0aed2e2faa3cfbba465e8 (patch)
treed864b40ccd44fe654bacc9b126390cd3c9bac3e9
parentb0b53ddfbbdf2d2f5923af2a8b73cc87d3165109 (diff)
compositor-drm: Clean up page_flip_pending path
page_flip_pending is only be set when do a pageflip to a newly-rendered buffer; if the flag is not set, we have landed in the start_repaint_loop path where the vblank query fails, and thus we must pageflip to the same buffer. This test was not sufficient for what it was supposed to guard: releasing framebuffers back. When using client-supplied framebuffers, it is possible to reuse the same buffer multiple times, and we would send a framebuffer-release event too early. However, since we have a properly reference-counted drm_fb now, we can just drop this test, and rely on the reference counting to prevent too-early release of client framebuffers. page_flip_pending now becomes exactly what the name suggests: a flag which indicates whether or not we are expecting a pageflip event. Add asserts here to verify that we never receive a pageflip event we weren't expecting. Signed-off-by: Daniel Stone <daniels@collabora.com> Differential Revision: https://phabricator.freedesktop.org/D1417
-rw-r--r--libweston/compositor-drm.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 1198a714..d4bba924 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -786,6 +786,7 @@ drm_output_repaint(struct weston_output *output_base,
output->fb_current = output->fb_pending;
output->fb_pending = NULL;
+ assert(!output->page_flip_pending);
output->page_flip_pending = 1;
drm_output_set_cursor(output);
@@ -907,12 +908,18 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
*/
fb_id = output->fb_current->fb_id;
+ assert(!output->page_flip_pending);
+ assert(!output->fb_last);
+
if (drmModePageFlip(backend->drm.fd, output->crtc_id, fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
weston_log("queueing pageflip failed: %m\n");
goto finish_frame;
}
+ output->fb_last = drm_fb_ref(output->fb_current);
+ output->page_flip_pending = 1;
+
return;
finish_frame:
@@ -972,16 +979,12 @@ page_flip_handler(int fd, unsigned int frame,
drm_output_update_msc(output, frame);
- /* We don't set page_flip_pending on start_repaint_loop, in that case
- * we just want to page flip to the current buffer to get an accurate
- * timestamp */
- if (output->page_flip_pending) {
- drm_fb_unref(output->fb_last);
- output->fb_last = NULL;
- }
-
+ assert(output->page_flip_pending);
output->page_flip_pending = 0;
+ drm_fb_unref(output->fb_last);
+ output->fb_last = NULL;
+
if (output->destroy_pending)
drm_output_destroy(&output->base);
else if (output->disable_pending)