summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglsync.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-04-10 13:16:30 +0200
committerMarek Olšák <[email protected]>2015-04-30 14:38:38 +0200
commit290a3eb7507f7f2949753a77c425ed2bb6fd0dd1 (patch)
tree3fba0561b8e7fd13910930c0ac326a8bb63d3bea /src/egl/main/eglsync.c
parenta8617cc0428dcc8340cb85776e122c6534a0fa11 (diff)
egl/dri2: implement EGL_KHR_cl_event2 (v2)
v2: fix the SYNC_CONDITION query
Diffstat (limited to 'src/egl/main/eglsync.c')
-rw-r--r--src/egl/main/eglsync.c62
1 files changed, 57 insertions, 5 deletions
diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c
index 9d0067caa2d..3b4a88902fd 100644
--- a/src/egl/main/eglsync.c
+++ b/src/egl/main/eglsync.c
@@ -65,25 +65,76 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
}
+static EGLint
+_eglParseSyncAttribList64(_EGLSync *sync, const EGLAttribKHR *attrib_list)
+{
+ EGLint i, err = EGL_SUCCESS;
+
+ if (!attrib_list)
+ return EGL_SUCCESS;
+
+ for (i = 0; attrib_list[i] != EGL_NONE; i++) {
+ EGLint attr = attrib_list[i++];
+ EGLint val = attrib_list[i];
+
+ switch (attr) {
+ case EGL_CL_EVENT_HANDLE_KHR:
+ if (sync->Type == EGL_SYNC_CL_EVENT_KHR) {
+ sync->CLEvent = val;
+ break;
+ }
+ /* fall through */
+ default:
+ (void) val;
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (err != EGL_SUCCESS) {
+ _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr);
+ break;
+ }
+ }
+
+ return err;
+}
+
+
EGLBoolean
_eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
- const EGLint *attrib_list)
+ const EGLint *attrib_list, const EGLAttribKHR *attrib_list64)
{
EGLint err;
if (!(type == EGL_SYNC_REUSABLE_KHR && dpy->Extensions.KHR_reusable_sync) &&
- !(type == EGL_SYNC_FENCE_KHR && dpy->Extensions.KHR_fence_sync))
+ !(type == EGL_SYNC_FENCE_KHR && dpy->Extensions.KHR_fence_sync) &&
+ !(type == EGL_SYNC_CL_EVENT_KHR && dpy->Extensions.KHR_cl_event2 &&
+ attrib_list64))
return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
_eglInitResource(&sync->Resource, sizeof(*sync), dpy);
sync->Type = type;
sync->SyncStatus = EGL_UNSIGNALED_KHR;
- sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
- err = _eglParseSyncAttribList(sync, attrib_list);
+ switch (type) {
+ case EGL_SYNC_CL_EVENT_KHR:
+ sync->SyncCondition = EGL_SYNC_CL_EVENT_COMPLETE_KHR;
+ break;
+ default:
+ sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
+ }
+
+ if (attrib_list64)
+ err = _eglParseSyncAttribList64(sync, attrib_list64);
+ else
+ err = _eglParseSyncAttribList(sync, attrib_list);
+
if (err != EGL_SUCCESS)
return _eglError(err, "eglCreateSyncKHR");
+ if (type == EGL_SYNC_CL_EVENT_KHR && !sync->CLEvent)
+ return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
+
return EGL_TRUE;
}
@@ -103,7 +154,8 @@ _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
*value = sync->SyncStatus;
break;
case EGL_SYNC_CONDITION_KHR:
- if (sync->Type != EGL_SYNC_FENCE_KHR)
+ if (sync->Type != EGL_SYNC_FENCE_KHR &&
+ sync->Type != EGL_SYNC_CL_EVENT_KHR)
return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR");
*value = sync->SyncCondition;
break;