By default, eglGetProcAddress does not work for EGL core functions. So, we need to manually search for the correct function to dispatch.
This patch just searches the currently linked in libraries in the default search order. Thus, it relies on the application to already be linked to the exact GL client library that it will be using. If it is linked to more than one GL client library, and they provide conflicting versions of the same gl function, then this might return the wrong function. This is just a fallback, though, to support basic gl core calls (glGetString, glGetIntegerv, glGetError, etc.) for EGL test cases. In fact, the vast majority of real tests will use waffle for EGL + GL dispatch. Signed-off-by: Daniel Kurtz <[email protected]> --- tests/util/piglit-dispatch-init.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/util/piglit-dispatch-init.c b/tests/util/piglit-dispatch-init.c index 22318a3..bfe0de9 100644 --- a/tests/util/piglit-dispatch-init.c +++ b/tests/util/piglit-dispatch-init.c @@ -37,6 +37,7 @@ # include "glxew.h" #elif defined(PIGLIT_HAS_EGL) # include <EGL/egl.h> +# include <dlfcn.h> #endif #endif @@ -143,6 +144,10 @@ get_core_proc_address(const char *function_name, int gl_10x_version) /** * This function is used to retrieve the address of all GL functions * on Linux. + * + * For standard EGL, this will only succeed if 'function_name is an extension + * function name. eglGetProcAddress() returns NULL if 'function_name is a + * core function unless the EGL also supports EGL_KHR_get_all_proc_addresses. */ static piglit_dispatch_function_ptr get_ext_proc_address(const char *function_name) @@ -164,12 +169,34 @@ get_ext_proc_address(const char *function_name) static piglit_dispatch_function_ptr get_core_proc_address(const char *function_name, int gl_10x_version) { - /* We don't need to worry about the GL version, since on Apple - * we retrieve all proc addresses in the same way. +#if defined(PIGLIT_HAS_EGL) + piglit_dispatch_function_ptr fn; + char *err; + + /* + * We don't worry about the GL version, we just retrieve the first + * matching proc address and hope for the best. + * In theory, we should use gl_10x_version, and the function "kind" + * (ie GL or GLES) to pick the right library to search. */ (void) gl_10x_version; + dlerror(); /* Clear dlerror */ + fn = dlsym(RTLD_DEFAULT, function_name); + err = dlerror(); + if (err) + fprintf(stderr, "dlsym(%s) => \"%s\"\n", function_name, err); + else + printf("dlsym(%s) => %p\n", __func__, function_name, gl_10x_version); + + return fn; +#else + /* We don't need to worry about the GL version, since on Linux + * we retrieve all proc addresses in the same way. + */ + (void) gl_10x_version; return get_ext_proc_address(function_name); +#endif } #endif -- 1.8.5.2 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
