X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fegl%2Fmain%2Feglsync.c;h=7b2c882d813c10c0938f51f46aeb1fb0608d2345;hb=2ba4c7e1548c6251085cd75563c182cc6708eaab;hp=b6c62d0087dac2001f45deea5b8851d85545bdaf;hpb=6c03c576cc49bbb008de66d374f4302ff0fe0390;p=mesa.git diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c index b6c62d0087d..7b2c882d813 100644 --- a/src/egl/main/eglsync.c +++ b/src/egl/main/eglsync.c @@ -1,118 +1,130 @@ +/************************************************************************** + * + * Copyright 2010 LunarG, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include #include #include "eglsync.h" #include "eglcurrent.h" +#include "egldriver.h" #include "egllog.h" -#ifdef EGL_KHR_reusable_sync - - /** * Parse the list of sync attributes and return the proper error code. */ static EGLint -_eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list) +_eglParseSyncAttribList(_EGLSync *sync, const EGLAttrib *attrib_list) { - EGLint i, err = EGL_SUCCESS; + EGLint i; 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]; + EGLAttrib attr = attrib_list[i++]; + EGLAttrib val = attrib_list[i]; + EGLint err = EGL_SUCCESS; switch (attr) { + case EGL_CL_EVENT_HANDLE_KHR: + if (sync->Type == EGL_SYNC_CL_EVENT_KHR) { + sync->CLEvent = val; + } else { + err = EGL_BAD_ATTRIBUTE; + } + break; default: - (void) val; err = EGL_BAD_ATTRIBUTE; break; } if (err != EGL_SUCCESS) { - _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr); - break; + _eglLog(_EGL_DEBUG, "bad sync attribute 0x%" PRIxPTR, attr); + return err; } } - return err; + return EGL_SUCCESS; } EGLBoolean _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, - const EGLint *attrib_list) + const EGLAttrib *attrib_list) { EGLint err; - if (!(type == EGL_SYNC_REUSABLE_KHR && dpy->Extensions.KHR_reusable_sync) && - !(type == EGL_SYNC_FENCE_KHR && dpy->Extensions.KHR_fence_sync)) - return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR"); - - memset(sync, 0, sizeof(*sync)); - - sync->Resource.Display = dpy; - + _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); - if (err != EGL_SUCCESS) - return _eglError(err, "eglCreateSyncKHR"); - - return EGL_TRUE; -} + 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; + } -_EGLSync * -_eglCreateSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, - EGLenum type, const EGLint *attrib_list) -{ - return NULL; -} + if (err != EGL_SUCCESS) + return _eglError(err, "eglCreateSyncKHR"); + if (type == EGL_SYNC_CL_EVENT_KHR && !sync->CLEvent) + return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR"); -EGLBoolean -_eglDestroySyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync) -{ return EGL_TRUE; } -EGLint -_eglClientWaitSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, - EGLint flags, EGLTimeKHR timeout) -{ - return EGL_FALSE; -} - - EGLBoolean -_eglSignalSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, - EGLenum mode) +_eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, + EGLint attribute, EGLAttrib *value) { - return EGL_FALSE; -} - - -EGLBoolean -_eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, - EGLint attribute, EGLint *value) -{ - if (!value) - return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs"); - switch (attribute) { case EGL_SYNC_TYPE_KHR: *value = sync->Type; break; case EGL_SYNC_STATUS_KHR: + /* update the sync status */ + 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)) + drv->API.ClientWaitSyncKHR(drv, dpy, sync, 0, 0); + *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; @@ -123,6 +135,3 @@ _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, return EGL_TRUE; } - - -#endif /* EGL_KHR_reusable_sync */