In the EGL destructor, DestroyThreadState gets called by
__eglCurrentTeardown to free the threadState, but the threadState does
not get changed to NULL when this happens.
The function eglReleaseThread calls __eglDestroyCurrentThreadAPIState,
which does set the threadState to NULL, right before calling
DestroyThreadState. Both eglReleaseThread and
__eglDestroyCurrentThreadAPIState check to make sure the threadState is
NULL before continuing.
If eglReleaseThread gets externally called after destruction, the
threadState is not NULL, so DestroyThreadState will be called to free
the threadState that was already freed by the destructor, causing a
double free.
This change is to add the same setting threadState to NULL in
__eglCurrentTeardown as which already __eglDestroyCurrentThreadAPIState,
to prevent this double free situation.
There are KHR, EXT, and NV versions of eglQueryDisplayAttrib, so add
support for all of them.
Define separate eglQueryDisplayAttribEXT, eglQueryDisplayAttribKHR, and
eglQueryDisplayAttribNV functions. They all call into the same common
function, with the only difference being the name passed to an error
callback.
When loading a vendor library, check for the vendor's
eglQueryDisplayAttrib using all three suffixes, and use whichever one is
available.
Add a dispatch stub for eglQueryDisplayAttribEXT, which updates the device
hashtable if the application queries EGL_DEVICE_EXT.
It's possible that eglQueryDisplayAttribEXT could return an EGLDeviceEXT handle
that wasn't returned by eglQueryDevicesEXT, so the dispatch stub needs to add
the handle to the device hashtable.
Export a new __EGLapiExports::setVendorForDevice function, which allows
dispatch stubs to update the device hashtable when something returns an
EGLDeviceEXT handle.
Bumped the ABI version number to 1.2.
It's possible for new devices to become available while a program is running,
so eglQueryDevicesEXT might need to return a different list.
Change the EGLDeviceEXT hashtable so that each entry is allocated and added
separately, rathat than allocating every entry in a single malloc.
Added a new __eglAddDevice function, which adds an entry to the device
hashtable.
When the application calls eglQueryDevicesEXT, always call through to each
vendor library, and add (or update) each EGLDeviceEXT to the hashtable.
There's still no provision for removing an entry from the device hashtable. The
semantics of hot-unplugging a device aren't defined yet, and there's no way to
ensure that libglvnd's mapping will get updated if a device disappears
asynchonously, so it's up to the vendor library to deal with the old handle.
If x11 support is enabled, then the meson and configure scripts will set
a macro named ENABLE_EGL_X11 instead of USE_X11.
USE_X11 will also select the Xlib typedef of EGLNativeDisplayType in
eglplatform.h, and libglvnd does not need or want those.
Enabling or disabling X11 support for EGL only affects platform
detection in eglGetDisplay. The rest of libEGL is supposed to treat
EGLNativeDisplayType as an opaque void* pointer.
This fixes the build for me since I have libX11 installed to a custom
prefix, so the default include path does not include libX11. This fixes
lots of instances of the following error:
../../libglvnd/include/EGL/eglplatform.h:109:10: fatal error: 'X11/Xlib.h' file not found
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Remove the "If only executable code is distributed..." paragraph from
the license text. Everything now uses a normal MIT license.
The only code from Khronos that's included in libglvnd is the EGL/GL
header and XML files, which do not contain that paragraph.
Fixes https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/221
Previously, relative ICD paths were treated as being relative to the
current working directory, but this doesn't seem useful in practice:
EGL vendors cannot predict what the current working directory of EGL
applications is going to be.
Instead, interpret the path as being relative to the realpath() of the
JSON manifest describing the ICD.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/190
Currently, in InitDeviceListInternal if any egl vendor fails to list
its devices for any reason the construction of the device list is
abandoned. That means that even if we have one vendor successfully
serving the application, the failure of another vendor library will
break any api calls related to egl devices.
Instead, if a vendor fails queryDevicesEXT the device mapping logic
should proceed as if it listed no devices. If the relevant device
belongs to the failed vendor then the dispatch will still fail with
EGL_BAD_DEVICE.
Theres a couple of things that this meson build system does differently
than autotools. It doesn't use a config.h file, it just puts #defines on
the command line with -D. It also does all of the code generation in the
generated folder, simply because it's simpler to do that.
On my 2 core / 4 thread KBL system:
autotools (no ccache):
sh -c "./autogen.sh&& ./configure && make -j6 check" 44.74s user 6.70s system 145% cpu 35.269 total
autotools (warm ccache):
sh -c "./autogen.sh&& ./configure && make -j6 check" 32.86s user 4.22s system 129% cpu 28.580 total
meson (no ccache):
sh -c "meson build; ninja -C build test" 23.48s user 3.71s system 236% cpu 11.487 total
meson (warm ccache)
sh -c "meson build; ninja -C build test" 16.06s user 2.31s system 210% cpu 8.727 total
These use the symbol-check.py script from mesa, and should help to
ensure that glvnd doesn't start exposing/hiding new symbols. It's also
useful to double check that meson and autotools are doing the same
thing.
The behaviour of a relative `library_path` is deliberately left
unspecified here. As an implementation detail, it's currently
passed directly to `dlopen()`, so in practice it will be interpreted as
relative to the process's current working directory, but that doesn't
seem practically useful. Vulkan treats relative paths as being relative
to the JSON file in which they were found, which seems more likely to
be a helpful behaviour.
Otherwise this documents the current behaviour, without any of the
possible changes suggested on #187. If any of those changes are made,
then this document should be updated at the same time.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Add a new configure option, --disable-x11. That option will disable GLX, and
will #ifdef out the X11 platform detection in EGL, but also remove the
dependency on the X11 libraries and headers.
In addition, only check for the xext and glproto packages if GLX is enabled,
since that's the only component that needs them.
This preserves the names from Mesa's gl, glesv1_cm, glesv2, and egl pkgconfig
data, and for compatibility with that, gl.pc gives you libGL.
Also added glx.pc and opengl.pc for libglvnd's libGLX and libOpenGL libraries.
If newer applications want to explicitly depend on libGLX and the appropriate
rendering API they can ask for the new pkgconfig names.
Note that the version numbers in each file are the API versions that each
library exposes, not the libglvnd package version.
An added advantage to this is that it makes it really easy to build with
Python 3, the same way other Autotools projects support it:
$ export PYTHON=/usr/bin/python3
$ ./configure
Remove FindProcIndex, __eglSetDispatchIndex, and
__eglDispatchFindDispatchFunction from egldispatchstubs.c.
The dispatch indices are allocated and assigned during initialization, so none
of those functions are ever called.
Don't point nonst_HEADERS or EXTRA_DIST at entire directories. That causes
"make dist" to include files that it shouldn't, such as configured makefiles
and .pyc files.
Also added a few generated header files to noinst_HEADERS.
The third parameter to mincore(2) can be a pointer to char or unsigned char,
depending on what system it's building on. To build in either case, just cast
that argument to a (void *).
Add an AC_CHECK_FUNC call to check whether dlopen is available without any
additional libraries. Some systems provide dlopen as part of libc, in which
case we can't (and don't need to) link against libdl.so.
When dlsym is handed an address in a shared object that doesn't match a symbol
in that shared object (such as a C++ vtable) it returns success but sets
dli_sname to null.
Handle this case rather than crashing.
If libglvnd is installed onto a system that already has non-libglvnd versions
of any of the OpenGL libraries installed, then ldconfig can get confused about
which files to create symlinks to. At worst, you could end up with a mix of the
libglvnd libraries and leftover non-libglvnd libraries.
To avoid that, bump the version numbers in these filenames:
- libGL.so.1.0.0 -> libGL.so.1.7.0
- libGLESv1_CM.so.1.0.0 -> libGLESv1_CM.so.1.2.0
- libGLESv2.so.2.0.0 -> libGLESv2.so.2.1.0
- libEGL.so.1.0.0 -> libEGL.so.1.1.0
Fixes https://github.com/NVIDIA/libglvnd/issues/147
EGL: Allow vendor libraries to identify platforms for eglGetDisplay.
Add a new optional function __EGLapiImports::findNativeDisplayPlatform. Vendor
libraries can provide that function to identify the platform for the native
display passed to eglGetDisplay.
Reviewed-by: Emil Velikov emil.velikov@collabora.com
Since the inseption of EGL/GBM the unofficial way to force
the platform was via EGL_PLATFORM="drm".
Strictly speaking one could remove the gbm one, but it should have no
side effects. Plus it's more consistent with other platforms.
In either case, one should not be using eglGetDisplay but the Platform
version of the API.
Signed-off-by: Emil Velikov <emil.velikov@gmail.com>
In eglGetDisplay, try to identify an X11 display based on a known function
pointer.
This is based on a patch by ajax@redhat.com:
https://github.com/NVIDIA/libglvnd/pull/102
The problem with using dlsym to look for wl_display_interface is that
variables by that name are emitted into other client libraries besides
libwayland-client. libSDL2 has this property, at least. Instead of that,
use dladdr() to look up the name of the symbol pointed to, and accept
any symbol with the right name as being wayland enough.
Signed-off-by: Adam Jackson <ajax@redhat.com>
v2: Minor formatting change.
In __eglFini, check for a fork, but don't call __glDispatchCheckMultithreaded.
If a vendor has patched the OpenGL entrypoints, then
__glDispatchCheckMultithreaded will try to call the vendor's thread attach
callback, but the vendor library may have already been unloaded.
Fixes https://github.com/NVIDIA/libglvnd/issues/103
Added a new function to libGLdispatch, __glDispatchForceUnpatch, which forces
it to unpatch the OpenGL entrypoints before libEGL or libGLX can unload the
vendor library that patched them.
If a vendor patches the OpenGL entrypoints, libGLdispatch doesn't unpatch them
when that vendor's context is no longer current, because that adds too much
overhead to repeated MakeCurrent+LoseCurrent calls. But, that also means that
the patch callbacks end up being dangling pointers after the vendor library is
unloaded.
This mainly shows up at process termination when a process loads both libEGL
and libGLX, because __glxFini and __eglFini will both call the vendor's
threadAttach callback.
Fixes https://github.com/NVIDIA/libglvnd/issues/103
Moved the UnionExtensionStrings and IntersectionExtensionStrings functions from
EGL to utils_misc.c.
Changed libGLX to use the common UnionExtensionStrings and IsTokenInString
functions instead of its own versions of them.
Moved ParseClientVersionString to libglx.c near where it's used, and deleted
libglxstring.c and libglxstring.h.