From 81bf993c6cb234e2b4550625bbba32a47183d1b5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 19 Sep 2014 14:53:01 +0900 Subject: [PATCH] Evas GL: Add support for fence_sync and similar extensions This should add support for the following EGL extensions: - EGL_KHR_fence_sync - EGL_KHR_reusable_sync (eglSignalSyncKHR) - EGL_KHR_wait_sync (eglWaitSyncKHR) @feature --- src/lib/evas/Evas_GL.h | 33 ++++++++++++ .../evas/engines/gl_common/evas_gl_api_ext.c | 54 +++++++++++++++++++ .../evas/engines/gl_common/evas_gl_api_ext_def.h | 62 ++++++++++++++++++++++ 3 files changed, 149 insertions(+) diff --git a/src/lib/evas/Evas_GL.h b/src/lib/evas/Evas_GL.h index d738a5f..c5e607a 100644 --- a/src/lib/evas/Evas_GL.h +++ b/src/lib/evas/Evas_GL.h @@ -1838,6 +1838,39 @@ EvasGLImage *img = glapi->evasglCreateImageForContext EvasGLImage (*evasglCreateImageForContext) (Evas_GL *evas_gl, Evas_GL_Context *ctx, int target, void* buffer, const int* attrib_list) EINA_WARN_UNUSED_RESULT; + + /*------- EvasGL / EGL-related functions -------*/ + /** + * @name Evas GL Sync object functions + * @since_tizen 2.3 + * @{ */ + /** + * @anchor evasglCreateSync + * @brief Requires the extension @c EGL_KHR_fence_sync, similar to eglCreateSyncKHR. + */ + EvasGLSync (*evasglCreateSync) (Evas_GL *evas_gl, unsigned int type, const int *attrib_list); + /** @anchor evasglDestroySync + * @brief Requires the extension @c EGL_KHR_fence_sync, similar to eglDestroySyncKHR. + */ + Eina_Bool (*evasglDestroySync) (Evas_GL *evas_gl, EvasGLSync sync); + /** @anchor evasglClientWaitSync + * @brief Requires the extension @c EGL_KHR_fence_sync, similar to eglClientWaitSyncKHR. + */ + int (*evasglClientWaitSync) (Evas_GL *evas_gl, EvasGLSync sync, int flags, EvasGLTime timeout); + /** @anchor evasglSignalSync + * @brief Requires the extension @c EGL_KHR_reusable_sync, similar to eglSignalSyncKHR. + */ + Eina_Bool (*evasglSignalSync) (Evas_GL *evas_gl, EvasGLSync sync, unsigned mode); + /** @anchor evasglGetSyncAttrib + * @brief Requires the extension @c EGL_KHR_fence_sync, similar to eglGetSyncAttribKHR. + */ + Eina_Bool (*evasglGetSyncAttrib) (Evas_GL *evas_gl, EvasGLSync sync, int attribute, int *value); + /** @anchor evasglWaitSync + * @brief Requires the extension @c EGL_KHR_wait_sync, similar to eglWaitSyncKHR. + */ + int (*evasglWaitSync) (Evas_GL *evas_gl, EvasGLSync sync, int flags); + /** @} */ + /* future calls will be added down here for expansion */ }; diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c index 077a26e..7a33f40 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c +++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c @@ -179,6 +179,60 @@ evgl_glEvasGLImageTargetRenderbufferStorage(GLenum target, EvasGLImage image) EXT_FUNC(glEGLImageTargetRenderbufferStorageOES)(target, image); } +static EvasGLSync +evgl_evasglCreateSync(Evas_GL *evas_gl EINA_UNUSED, + unsigned int type, const int *attrib_list) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return NULL; + return EXT_FUNC(eglCreateSyncKHR)(dpy, type, attrib_list); +} + +static Eina_Bool +evgl_evasglDestroySync(Evas_GL *evas_gl EINA_UNUSED, EvasGLSync sync) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return EINA_FALSE; + return EXT_FUNC(eglDestroySyncKHR)(dpy, sync); +} + +static int +evgl_evasglClientWaitSync(Evas_GL *evas_gl EINA_UNUSED, + EvasGLSync sync, int flags, EvasGLTime timeout) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return EINA_FALSE; + return EXT_FUNC(eglClientWaitSyncKHR)(dpy, sync, flags, timeout); +} + +static Eina_Bool +evgl_evasglSignalSync(Evas_GL *evas_gl EINA_UNUSED, + EvasGLSync sync, unsigned mode) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return EINA_FALSE; + return EXT_FUNC(eglSignalSyncKHR)(dpy, sync, mode); +} + +static Eina_Bool +evgl_evasglGetSyncAttrib(Evas_GL *evas_gl EINA_UNUSED, + EvasGLSync sync, int attribute, int *value) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return EINA_FALSE; + return EXT_FUNC(eglGetSyncAttribKHR)(dpy, sync, attribute, value); +} + +static int +evgl_evasglWaitSync(Evas_GL *evas_gl EINA_UNUSED, + EvasGLSync sync, int flags) +{ + EGLDisplay dpy = EGLDISPLAY_GET(); + if (!dpy) return EINA_FALSE; + return EXT_FUNC(eglWaitSyncKHR)(dpy, sync, flags); +} + + #else #endif diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h index 4e64df9..c8986d7 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h +++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h @@ -565,6 +565,67 @@ _EVASGL_EXT_BEGIN(EGL_KHR_gl_renderbuffer_image) #endif _EVASGL_EXT_END() +_EVASGL_EXT_BEGIN(EGL_KHR_fence_sync) + + _EVASGL_EXT_DRVNAME(EGL_KHR_fence_sync) + + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(void *, eglCreateSyncKHR, (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglCreateSyncKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(EGLBoolean, eglDestroySyncKHR, (EGLDisplay dpy, EGLSyncKHR sync)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglDestroySyncKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(EGLint, eglClientWaitSyncKHR, (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglClientWaitSyncKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(EGLBoolean, eglGetSyncAttribKHR, (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglGetSyncAttribKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + + _EVASGL_EXT_FUNCTION_BEGIN(EvasGLSync, evasglCreateSync, (Evas_GL *evas_gl, unsigned int type, const int *attrib_list)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglCreateSync) + _EVASGL_EXT_FUNCTION_END() + _EVASGL_EXT_FUNCTION_BEGIN(Eina_Bool, evasglDestroySync, (Evas_GL *evas_gl, EvasGLSync sync)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglDestroySync) + _EVASGL_EXT_FUNCTION_END() + _EVASGL_EXT_FUNCTION_BEGIN(int, evasglClientWaitSync, (Evas_GL *evas_gl, EvasGLSync sync, int flags, EvasGLTime timeout)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglClientWaitSync) + _EVASGL_EXT_FUNCTION_END() + _EVASGL_EXT_FUNCTION_BEGIN(Eina_Bool, evasglGetSyncAttrib, (Evas_GL *evas_gl, EvasGLSync sync, int attribute, int *value)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglGetSyncAttrib) + _EVASGL_EXT_FUNCTION_END() + +_EVASGL_EXT_END() + +_EVASGL_EXT_BEGIN(EGL_KHR_reusable_sync) + + _EVASGL_EXT_DRVNAME(EGL_KHR_reusable_sync) + + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(EGLBoolean, eglSignalSyncKHR, (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglSignalSyncKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + + _EVASGL_EXT_FUNCTION_BEGIN(Eina_Bool, evasglSignalSync, (Evas_GL *evas_gl, EvasGLSync sync, unsigned mode)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglSignalSync) + _EVASGL_EXT_FUNCTION_END() + +_EVASGL_EXT_END() + +_EVASGL_EXT_BEGIN(EGL_KHR_wait_sync) + + _EVASGL_EXT_DRVNAME(EGL_KHR_wait_sync) + + _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(EGLint, eglWaitSyncKHR, (EGLDisplay dpy, EGLSyncKHR sync, int flags)) + _EVASGL_EXT_FUNCTION_DRVFUNC(GETPROCADDR("eglWaitSyncKHR")) + _EVASGL_EXT_FUNCTION_PRIVATE_END() + + _EVASGL_EXT_FUNCTION_BEGIN(int, evasglWaitSync, (Evas_GL *evas_gl, EvasGLSync sync, int flags)) + _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_evasglWaitSync) + _EVASGL_EXT_FUNCTION_END() + +_EVASGL_EXT_END() + + #if 0 _EVASGL_EXT_BEGIN(EGL_SEC_map_image) _EVASGL_EXT_DRVNAME(EGL_SEC_map_image) @@ -578,6 +639,7 @@ _EVASGL_EXT_BEGIN(EGL_SEC_map_image) _EVASGL_EXT_END() #endif + #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- 2.7.4