3f51e89acd609ef268236f7c581ebe640dbb7a31
[mesa.git] / src / egl / main / eglsync.c
1 #include <string.h>
2
3 #include "eglsync.h"
4 #include "eglcurrent.h"
5 #include "egllog.h"
6
7
8 #ifdef EGL_KHR_reusable_sync
9
10
11 /**
12 * Parse the list of sync attributes and return the proper error code.
13 */
14 static EGLint
15 _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
16 {
17 EGLint i, err = EGL_SUCCESS;
18
19 if (!attrib_list)
20 return EGL_SUCCESS;
21
22 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
23 EGLint attr = attrib_list[i++];
24 EGLint val = attrib_list[i];
25
26 switch (attr) {
27 default:
28 (void) val;
29 err = EGL_BAD_ATTRIBUTE;
30 break;
31 }
32
33 if (err != EGL_SUCCESS) {
34 _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr);
35 break;
36 }
37 }
38
39 return err;
40 }
41
42
43 EGLBoolean
44 _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
45 const EGLint *attrib_list)
46 {
47 EGLint err;
48
49 if (!(type == EGL_SYNC_REUSABLE_KHR && dpy->Extensions.KHR_reusable_sync))
50 return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
51
52 memset(sync, 0, sizeof(*sync));
53
54 sync->Resource.Display = dpy;
55
56 sync->Type = type;
57 sync->SyncStatus = EGL_UNSIGNALED_KHR;
58
59 err = _eglParseSyncAttribList(sync, attrib_list);
60 if (err != EGL_SUCCESS)
61 return _eglError(err, "eglCreateSyncKHR");
62
63 return EGL_TRUE;
64 }
65
66
67 _EGLSync *
68 _eglCreateSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy,
69 EGLenum type, const EGLint *attrib_list)
70 {
71 return NULL;
72 }
73
74
75 EGLBoolean
76 _eglDestroySyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync)
77 {
78 return EGL_TRUE;
79 }
80
81
82 EGLint
83 _eglClientWaitSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
84 EGLint flags, EGLTimeKHR timeout)
85 {
86 return EGL_FALSE;
87 }
88
89
90 EGLBoolean
91 _eglSignalSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
92 EGLenum mode)
93 {
94 return EGL_FALSE;
95 }
96
97
98 EGLBoolean
99 _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
100 EGLint attribute, EGLint *value)
101 {
102 if (!value)
103 return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs");
104
105 switch (attribute) {
106 case EGL_SYNC_TYPE_KHR:
107 *value = sync->Type;
108 break;
109 case EGL_SYNC_STATUS_KHR:
110 *value = sync->SyncStatus;
111 break;
112 default:
113 return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR");
114 break;
115 }
116
117 return EGL_TRUE;
118 }
119
120
121 #endif /* EGL_KHR_reusable_sync */