From 0201f01dc4e903d9b60cbbf87fde3ffa7c76f248 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 18 Nov 2016 08:39:33 -0500 Subject: egl: add EGL_ANDROID_native_fence_sync With fixes from Chad squashed in, plus fixes for issues that Rafael found while writing piglit tests. Signed-off-by: Rob Clark Tested-by: Rafael Antognolli Reviewed-by: Chad Versace Tested-by: Chad Versace --- src/egl/main/eglsync.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/egl/main/eglsync.c') diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c index 7b2c882d813..cb931b81682 100644 --- a/src/egl/main/eglsync.c +++ b/src/egl/main/eglsync.c @@ -59,6 +59,14 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLAttrib *attrib_list) err = EGL_BAD_ATTRIBUTE; } break; + case EGL_SYNC_NATIVE_FENCE_FD_ANDROID: + if (sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID) { + /* we take ownership of the native fd, so no dup(): */ + sync->SyncFd = val; + } else { + err = EGL_BAD_ATTRIBUTE; + } + break; default: err = EGL_BAD_ATTRIBUTE; break; @@ -83,6 +91,7 @@ _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, _eglInitResource(&sync->Resource, sizeof(*sync), dpy); sync->Type = type; sync->SyncStatus = EGL_UNSIGNALED_KHR; + sync->SyncFd = EGL_NO_NATIVE_FENCE_FD_ANDROID; err = _eglParseSyncAttribList(sync, attrib_list); @@ -90,6 +99,12 @@ _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, case EGL_SYNC_CL_EVENT_KHR: sync->SyncCondition = EGL_SYNC_CL_EVENT_COMPLETE_KHR; break; + case EGL_SYNC_NATIVE_FENCE_ANDROID: + if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) + sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; + else + sync->SyncCondition = EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID; + break; default: sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; } @@ -117,17 +132,20 @@ _eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, if (sync->SyncStatus != EGL_SIGNALED_KHR && (sync->Type == EGL_SYNC_FENCE_KHR || sync->Type == EGL_SYNC_CL_EVENT_KHR || - sync->Type == EGL_SYNC_REUSABLE_KHR)) + sync->Type == EGL_SYNC_REUSABLE_KHR || + sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID)) drv->API.ClientWaitSyncKHR(drv, dpy, sync, 0, 0); *value = sync->SyncStatus; break; case EGL_SYNC_CONDITION_KHR: if (sync->Type != EGL_SYNC_FENCE_KHR && - sync->Type != EGL_SYNC_CL_EVENT_KHR) + sync->Type != EGL_SYNC_CL_EVENT_KHR && + sync->Type != EGL_SYNC_NATIVE_FENCE_ANDROID) return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); *value = sync->SyncCondition; break; + default: return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); break; -- cgit v1.2.3