diff options
author | Chia-I Wu <[email protected]> | 2009-09-28 14:12:39 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-10-15 12:54:00 -0600 |
commit | 6c21c8862bc6edc9cddf3b6eb6f276961099a7a8 (patch) | |
tree | 2a4ead835862bdb82e0894259dff143ae4849975 /src | |
parent | 57da499d7ba074128e8c97b8076805e403a2b9c4 (diff) |
egl: Rework the synchronization primitives.
This adds error checking to the synchronization primitives. And
eglWaitGL is now implemented by eglWaitClient.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/main/eglapi.c | 66 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 6 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 2 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 3 | ||||
-rw-r--r-- | src/egl/main/eglmisc.h | 2 |
5 files changed, 48 insertions, 31 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 5ce04693519..14cc5fa6137 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -558,32 +558,66 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) EGLBoolean EGLAPIENTRY -eglWaitGL(void) +eglWaitClient(void) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); + + return drv->API.WaitClient(drv, disp, ctx); +} + - return drv->API.WaitGL(drv, disp); +EGLBoolean EGLAPIENTRY +eglWaitGL(void) +{ +#ifdef EGL_VERSION_1_2 + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = t->CurrentAPIIndex; + EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API); + EGLBoolean ret; + + if (api_index != es_index && _eglIsCurrentThreadDummy()) + return _eglError(EGL_BAD_ALLOC, "eglWaitGL"); + + t->CurrentAPIIndex = es_index; + ret = eglWaitClient(); + t->CurrentAPIIndex = api_index; + return ret; +#else + return eglWaitClient(); +#endif } EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); return drv->API.WaitNative(drv, disp, engine); } @@ -958,20 +992,4 @@ eglReleaseThread(void) } -EGLBoolean -eglWaitClient(void) -{ - _EGLDisplay *disp = _eglGetCurrentDisplay(); - _EGLDriver *drv; - - if (!disp) - return EGL_TRUE; - - /* a current display is always initialized */ - drv = disp->Driver; - - return drv->API.WaitClient(drv, disp); -} - - #endif /* EGL_VERSION_1_2 */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index feb35c863c4..aa0abe3eb6b 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -41,7 +41,7 @@ typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurfa /* misc funcs */ typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); -typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, _EGLDisplay *dpy); +typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine); typedef _EGLProc (*GetProcAddress_t)(const char *procname); @@ -65,7 +65,6 @@ typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, #ifdef EGL_VERSION_1_2 -typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy); typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list); #endif /* EGL_VERSION_1_2 */ @@ -101,7 +100,7 @@ struct _egl_api CopyBuffers_t CopyBuffers; QueryString_t QueryString; - WaitGL_t WaitGL; + WaitClient_t WaitClient; WaitNative_t WaitNative; GetProcAddress_t GetProcAddress; @@ -120,7 +119,6 @@ struct _egl_api QueryModeStringMESA_t QueryModeStringMESA; #ifdef EGL_VERSION_1_2 - WaitClient_t WaitClient; CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; #endif }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 0c76c799738..018b06d3bea 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -408,7 +408,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.CopyBuffers = _eglCopyBuffers; drv->API.QueryString = _eglQueryString; - drv->API.WaitGL = _eglWaitGL; + drv->API.WaitClient = _eglWaitClient; drv->API.WaitNative = _eglWaitNative; #ifdef EGL_MESA_screen_surface diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index b37213faf10..e66913320b2 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -108,11 +108,12 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) EGLBoolean -_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy) +_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { /* just a placeholder */ (void) drv; (void) dpy; + (void) ctx; return EGL_TRUE; } diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h index a15c839be2b..829d4cde792 100644 --- a/src/egl/main/eglmisc.h +++ b/src/egl/main/eglmisc.h @@ -37,7 +37,7 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); extern EGLBoolean -_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy); +_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); extern EGLBoolean |