From 14f24485e33816139398d1bd170d617703473738 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 17 Mar 2014 11:17:19 -0700 Subject: [PATCH] Add support for looking up GLES3 functions using dlsym(). ARM and Mesa disagreed on how to look up the functions, so support both ways. Fixes #21 --- src/dispatch_common.c | 23 ++++++++++++++++++++++- src/dispatch_common.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/dispatch_common.c b/src/dispatch_common.c index dce2601..f6d69e0 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -207,7 +207,7 @@ do_dlsym(void **handle, const char *lib_name, const char *name, #else result = dlsym(*handle, name); #endif - if (!result) { + if (!result && exit_on_fail) { fprintf(stderr,"%s() not found in %s\n", name, lib_name); exit(1); } @@ -381,6 +381,27 @@ epoxy_gles2_dlsym(const char *name) return do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, true); } +/** + * Does the appropriate dlsym() or eglGetProcAddress() for GLES3 + * functions. + * + * Mesa interpreted GLES as intending that the GLES3 functions were + * available only through eglGetProcAddress() and not dlsym(), while + * ARM's Mali drivers interpreted GLES as intending that GLES3 + * functions were available only through dlsym() and not + * eglGetProcAddress(). Thanks, Khronos. + */ +void * +epoxy_gles3_dlsym(const char *name) +{ + void *func = do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, false); + + if (func) + return func; + + return epoxy_get_proc_address(name); +} + /** * Performs either the dlsym or glXGetProcAddress()-equivalent for * core functions in desktop GL. diff --git a/src/dispatch_common.h b/src/dispatch_common.h index a70753a..a0722ff 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -78,6 +78,7 @@ void *epoxy_glx_dlsym(const char *name); void *epoxy_gl_dlsym(const char *name); void *epoxy_gles1_dlsym(const char *name); void *epoxy_gles2_dlsym(const char *name); +void *epoxy_gles3_dlsym(const char *name); void *epoxy_get_proc_address(const char *name); void *epoxy_get_core_proc_address(const char *name, int core_version); void *epoxy_get_bootstrap_proc_address(const char *name);