egl: Create queryable strings in eglInitialize().

Graphics / Mesa 3D Graphics Library / Mesa - Matt Turner [gmail.com] - 13 March 2015 12:42 UTC

Creating/recreating the strings in eglQueryString() is extra work and isn't thread-safe, as exhibited by shader-db's run.c using libepoxy.

Multiple threads in run.c call eglReleaseThread() around the same time. libepoxy calls eglQueryString() to determine whether eglReleaseThread() exists, and our EGL implementation passes a pointer to the version string to libepoxy while simultaneously overwriting the string, leading to a failure in libepoxy.

Moreover, the EGL spec says (emphasis mine):

"eglQueryString returns a pointer to a *static*, zero-terminated string"

This patch moves some auxiliary functions from eglmisc.c to eglapi.c so that they may be used to create the extension, API, and version strings once during eglInitialize(). The auxiliary functions are renamed from _eglUpdate* to _eglCreate*, and some checks made unnecessary by calling the functions from eglInitialize() are removed.

dac2e7d egl: Create queryable strings in eglInitialize().
src/egl/main/eglapi.c | 112 +++++++++++++++++++++++++++++++++++++++++++
src/egl/main/eglmisc.c | 125 ------------------------------------------------
2 files changed, 112 insertions(+), 125 deletions(-)

Upstream: cgit.freedesktop.org


  • Share