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.
int fence_fd = -1;
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.
Should be fixed as of
Author: Zhongmin Wu <firstname.lastname@example.org>
Date: Fri Sep 15 18:32:43 2017 +0100
egl/android: Use per surface out fence