aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorZhongmin Wu <[email protected]>2017-09-15 18:32:43 +0100
committerEmil Velikov <[email protected]>2017-09-19 12:12:29 +0100
commit7343d271367d9a15063ea8093108f829eb593c8d (patch)
tree5058e7f31d87bc0c9e31a11ee9ba0968f175ba12 /src/egl/drivers
parente013ce8d0d91f6558af50f285e6a96ab697ec90c (diff)
egl/android: Use per surface out fence
Use the plumbing introduced with previous patch to interact with the Android framework. Namely: currently we use an invalid fd of -1 for our calls to ANativeWindow::{queue,cancel}Buffer. At the same time applications (like flatland) may rely on it being a valid one. Thus as they attempt to query the timestamp of the fence, they get unexpected results/behaviour. In the case of flatland - the benchmark hang inside getSignalTime(). Make use of the out fence and pass the correct fd to Android. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101655 Signed-off-by: Zhongmin Wu <[email protected]> Signed-off-by: Yogesh Marathe <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Tomasz Figa <[email protected]> [Emil Velikov: split from larger patch] Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/platform_android.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 38c1122339f..d08a8b22b7d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -229,19 +229,18 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur
*/
mtx_unlock(&disp->Mutex);
- /* Queue the buffer without a sync fence. This informs the ANativeWindow
- * that it may access the buffer immediately.
+ /* Queue the buffer with stored out fence fd. The ANativeWindow or buffer
+ * consumer may choose to wait for the fence to signal before accessing
+ * it. If fence fd value is -1, buffer can be accessed by consumer
+ * immediately. Consumer or application shouldn't rely on timestamp
+ * associated with fence if the fence fd is -1.
*
- * From ANativeWindow::dequeueBuffer:
- *
- * The fenceFd argument specifies a libsync fence file descriptor for
- * a fence that must signal before the buffer can be accessed. If
- * the buffer can be accessed immediately then a value of -1 should
- * be used. The caller must not use the file descriptor after it
- * is passed to queueBuffer, and the ANativeWindow implementation
- * is responsible for closing it.
+ * Ownership of fd is transferred to consumer after queueBuffer and the
+ * consumer is responsible for closing it. Caller must not use the fd
+ * after passing it to queueBuffer.
*/
- int fence_fd = -1;
+ int fence_fd = dri2_surf->out_fence_fd;
+ dri2_surf->out_fence_fd = -1;
dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
fence_fd);
@@ -263,8 +262,11 @@ static void
droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
{
int ret;
+ int fence_fd = dri2_surf->out_fence_fd;
- ret = dri2_surf->window->cancelBuffer(dri2_surf->window, dri2_surf->buffer, -1);
+ dri2_surf->out_fence_fd = -1;
+ ret = dri2_surf->window->cancelBuffer(dri2_surf->window,
+ dri2_surf->buffer, fence_fd);
if (ret < 0) {
_eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed");
dri2_surf->base.Lost = EGL_TRUE;
@@ -289,7 +291,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
return NULL;
}
- if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, false))
+ if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, true))
goto cleanup_surface;
if (type == EGL_WINDOW_BIT) {