[Piglit] [PATCH] dispatch: Fix lookup for core OpenGL symbols

Marek Olšák maraeo at gmail.com
Thu Apr 30 02:16:44 PDT 2015


Thanks for doing this.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Thu, Apr 30, 2015 at 4:29 AM, Chad Versace <chad.versace at intel.com> wrote:
> The following commit regressed lookup of some new OpenGL symbols:
>
>     commit cb334db3f2bb7ddf9b2f43641f898896f99c69b1
>     Author: Daniel Kurtz <djkurtz at chromium.org>
>     Date:   Thu Oct 16 21:36:01 2014 +0800
>     Subject: dispatch: Use dlsym to lookup core symbols for EGL (v2)
>
> It regressed these Piglit tests on i965:
>     spec at arb_pipeline_statistics_query@arb_pipeline_statistics_query-vert_adj
>     spec at arb_pipeline_statistics_query@arb_pipeline_statistics_query-geom
>
> Fix the tests by consistently using egl/glXGetProcAddress to lookup core
> OpenGL symbols instead of dlsym(), and add a lengthy comment explaining
> why. (For core OpenGL ES symbols, continue using dlsym() as in
> cb334db3).
>
> Cc: Marek Olšák <marek.olsak at amd.com>
> Cc: Mark Janes <mark.a.janes at intel.com>
> Cc: Daniel Kurtz <djkurtz at chromium.org>
> ---
>  tests/util/piglit-dispatch-init.c | 42 +++++++++++++++++++++++++++++----------
>  1 file changed, 31 insertions(+), 11 deletions(-)
>
> diff --git a/tests/util/piglit-dispatch-init.c b/tests/util/piglit-dispatch-init.c
> index a47d4cc..ead6d2f 100644
> --- a/tests/util/piglit-dispatch-init.c
> +++ b/tests/util/piglit-dispatch-init.c
> @@ -157,13 +157,9 @@ get_core_proc_address(const char *function_name, int gl_10x_version)
>  #else /* Linux */
>
>  #if defined(PIGLIT_HAS_EGL)
> -#define GLX_LIB "libGL.so.1"
>  #define GLES1_LIB "libGLESv1_CM.so.1"
>  #define GLES2_LIB "libGLESv2.so.2"
>
> -/** dlopen() return value for libGL.so.1 */
> -static void *glx_handle;
> -
>  /** dlopen() return value for libGLESv1_CM.so.1 */
>  static void *gles1_handle;
>
> @@ -213,11 +209,32 @@ get_ext_proc_address(const char *function_name)
>   * This function is used to retrieve the address of core GL functions
>   * on Linux.
>   *
> - * eglGetProcAddress supports querying core functions only if EGL >= 1.5
> - * or if EGL_KHR_get_all_proc_addresses or
> - * EGL_KHR_client_get_all_proc_addresses is supported. Rather than worry
> - * about such details, when using EGL we consistently use dlsym() on the
> - * client library to lookup core functions.
> + * eglGetProcAddress supports querying core functions only if EGL >= 1.5 or if
> + * EGL_KHR_get_all_proc_addresses or EGL_KHR_client_get_all_proc_addresses is
> + * supported. Rather than worry about such details, we consistently use dlysm()
> + * to lookup core *OpenGL ES* functions on systems where EGL is available.
> + *
> + * Lookup for core *OpenGL* functions is more complicated because the EGL 1.4
> + * specification, the antiquated OpenGL ABI for Linux [1] from year 2000, and
> + * various libGL.so implementations all disagree on the set of symbols that
> + * libGL.so should statically expose and which are queryable with
> + * eglGetProcAddress.  The EGL 1.4 spec (as explained above) does not require
> + * eglGetProcAddress to work for core functions.  The OpenGL ABI spec requires
> + * that libGL.so expose *no* symbols statically except those contained in GL
> + * 1.2 and select extensions. Actual driver vendors tend to expose most, if not
> + *   all, symbols statically from libGL.so.
> + *
> + * Considering how messy this situation is, the best way to query a core OpenGL
> + * function on EGL is eglGetProcAddress (or even glXGetProcAddress!). Sometimes
> + * Mesa's libGL doesn't statically expose all OpenGL functions supported by the
> + * driver, but Mesa's eglGetProcAddress does work for all GL functions, core
> + * and extension.  Some other vendors of desktop OpenGL drivers, such as
> + * Nvidia, do the same. (By coincidence, Mesa's glXGetProcAddress also returns
> + * the same addresses as eglGetProcAddress). We don't need to worry about
> + * platforms on which eglGetProcAddress does not work for core functions, such
> + * as Mali, because those platforms support only OpenGL ES.
> + *
> + * [1] https://www.opengl.org/registry/ABI/
>   */
>  static piglit_dispatch_function_ptr
>  get_core_proc_address(const char *function_name, int gl_10x_version)
> @@ -230,8 +247,11 @@ get_core_proc_address(const char *function_name, int gl_10x_version)
>                 return do_dlsym(&gles2_handle, GLES2_LIB, function_name);
>         case 10:
>         default:
> -               /* GL does not have its own library, so use GLX */
> -               return do_dlsym(&glx_handle, GLX_LIB, function_name);
> +               /* We query the address of core OpenGL functions as if they
> +                * were extension functions. Read about the gory details
> +                * above. */
> +               (void) gl_10x_version;
> +               return get_ext_proc_address(function_name);
>         }
>  #else
>         /* We don't need to worry about the GL version, since when using GLX
> --
> 2.3.6
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list