[Mesa-dev] [PATCH 1/2] egl: declare dri2_glFlush using a macro
Tapani Pälli
tapani.palli at intel.com
Wed May 9 05:28:58 UTC 2018
ping ..
On 03.05.2018 19:00, Tapani Pälli wrote:
> This is done to avoid having same code for multiple
> entrypoints, next patch wants to utilize glFinish.
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/egl/drivers/dri2/egl_dri2.c | 44 +++++++++++++++++++++--------------------
> 1 file changed, 23 insertions(+), 21 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 45d0c7275c..de56c16221 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -104,25 +104,27 @@ dri_set_background_context(void *loaderPrivate)
> _eglBindContextToThread(ctx, t);
> }
>
> -static void
> -dri2_gl_flush()
> -{
> - static void (*glFlush)(void);
> - static mtx_t glFlushMutex = _MTX_INITIALIZER_NP;
> -
> - mtx_lock(&glFlushMutex);
> - if (!glFlush)
> - glFlush = _glapi_get_proc_address("glFlush");
> - mtx_unlock(&glFlushMutex);
> -
> - /* if glFlush is not available things are horribly broken */
> - if (!glFlush) {
> - _eglLog(_EGL_WARNING, "DRI2: failed to find glFlush entry point");
> - return;
> - }
> -
> - glFlush();
> -}
> +typedef void (*funcp) (void);
> +
> +#define DECL_GLCALL(x) \
> +static void dri2_##x() \
> +{\
> + static funcp func##x = NULL;\
> + static mtx_t mutex = _MTX_INITIALIZER_NP;\
> + mtx_lock(&mutex);\
> + if (!func##x)\
> + func##x = _glapi_get_proc_address(#x);\
> + mtx_unlock(&mutex);\
> + if (!func##x) {\
> + _eglLog(_EGL_WARNING, "DRI2: failed to find " #x "entry point");\
> + return;\
> + }\
> + func##x();\
> +}\
> +
> +DECL_GLCALL(glFlush);
> +
> +#undef DECL_GLCALL
>
> static GLboolean
> dri_is_thread_safe(void *loaderPrivate)
> @@ -1511,7 +1513,7 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
>
> /* flush before context switch */
> if (old_ctx)
> - dri2_gl_flush();
> + dri2_glFlush();
>
> ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
> rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
> @@ -3081,7 +3083,7 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
> if (dri2_ctx && dri2_sync->base.SyncStatus == EGL_UNSIGNALED_KHR &&
> (flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)) {
> /* flush context if EGL_SYNC_FLUSH_COMMANDS_BIT_KHR is set */
> - dri2_gl_flush();
> + dri2_glFlush();
> }
>
> /* if timeout is EGL_FOREVER_KHR, it should wait without any timeout.*/
>
More information about the mesa-dev
mailing list