1 /**************************************************************************
3 * Copyright 2010 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 #include "eglcurrent.h"
37 * Parse the list of sync attributes and return the proper error code.
40 _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
42 EGLint i, err = EGL_SUCCESS;
47 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
48 EGLint attr = attrib_list[i++];
49 EGLint val = attrib_list[i];
54 err = EGL_BAD_ATTRIBUTE;
58 if (err != EGL_SUCCESS) {
59 _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr);
69 _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
70 const EGLint *attrib_list)
74 if (!(type == EGL_SYNC_REUSABLE_KHR && dpy->Extensions.KHR_reusable_sync) &&
75 !(type == EGL_SYNC_FENCE_KHR && dpy->Extensions.KHR_fence_sync))
76 return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
78 _eglInitResource(&sync->Resource, sizeof(*sync), dpy);
80 sync->SyncStatus = EGL_UNSIGNALED_KHR;
81 sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
83 err = _eglParseSyncAttribList(sync, attrib_list);
84 if (err != EGL_SUCCESS)
85 return _eglError(err, "eglCreateSyncKHR");
92 _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
93 EGLint attribute, EGLint *value)
96 return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs");
99 case EGL_SYNC_TYPE_KHR:
102 case EGL_SYNC_STATUS_KHR:
103 *value = sync->SyncStatus;
105 case EGL_SYNC_CONDITION_KHR:
106 if (sync->Type != EGL_SYNC_FENCE_KHR)
107 return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR");
108 *value = sync->SyncCondition;
111 return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR");