Bug 101655 - Explicit sync support for android
Summary: Explicit sync support for android
Alias: None
Product: Mesa
Classification: Unclassified
Component: EGL (show other bugs)
Version: 17.1
Hardware: Other other
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2017-06-30 04:14 UTC by Yogesh Marathe
Modified: 2017-09-19 11:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Yogesh Marathe 2017-06-30 04:14:36 UTC
Description: The explicit sync was introduced in android to have sync fds passed between user space processes and let user insert waits for buffer transcations as appropriate. In android, if there is a producer-consumer scenario in framework and if mesa is being used underneath this explicit sync wouldn't work because the fence_fd is being forced to -1 before enqueue. The comments above this assignment clearly state why its doing so, although it seems old and assumes that consumer will never want use that fd to get a signal timestamp using libsync apis or wait on that fd. Acquire fence on consumer side remains always invalid due to this.

File: platform_android.c

Function: droid_window_enqueue_buffer()
    int fence_fd = -1;
   dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,

Test case: flatland - provided though aosp under
framworks/native/cmds/flatland is an app that tests explicit functionality on android. 

Symptoms and Cause: flatland hangs because it tries to do getSignalTime() for this acquire fence_fd on consumer side and uses that to calculate time elapsed for doing one frame of particular resolution.

1. Flatland should work as standalone test case with mesa.
2. To support explicit sync, it should forward a valid fence for a buffer being enqueued (it can also be a signaled one if buffer is immediately available for consumption).

I tried, if a sync fence can be created before buffer is enqueued but didnt find a way because all sync functions seem to be static in nature and exposed only though egl apis. I don't know if there is any other way to call those functions (e.g. dri2_create_sync etc.) from platform_android.c directly.
Comment 1 Emil Velikov 2017-09-19 11:20:43 UTC
Should be fixed as of

commit 7343d271367d9a15063ea8093108f829eb593c8d
Author: Zhongmin Wu <zhongmin.wu@intel.com>
Date:   Fri Sep 15 18:32:43 2017 +0100

    egl/android: Use per surface out fence

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.