Replaced testpatchentrypoints_gldispatch with three new unit tests.
testgldispatch_static and testgldispatch_generated test dispatching to multiple
vendor libraries through static and generated dispatch stubs, respectively.
testgldispatch_generated tests entrypoint patching and unpatching. This adds
coverage for patching generated stubs in addition to the static ones.
The entrypoint patching functions in tests/dummy/patchentrypoints.c now take
the name of the function to patch, instead of hard-coding it to only patch
glVertex3fv.
Added three new configure options to disable building the EGL, GLX, GLES
libraries.
In the tests makefile, move the list of test scripts to separate unconditional
variables, and add those to EXTRA_DIST. Just conditionally adding variables to
TESTS isn't enough to include the test scripts in the dist package.
Split up the TESTS and check_PROGRAMS variable assignments, so that they're
assigned next to the commands to build each test.
In addition to better readability and making it easier to avoid merge
conflicts, this will allow making some of the tests conditional based on build
options.
Remove the __GLdispatchProcEntry struct and list, and remove the generation
counter for the dispatch tables and stubs.
Generated stubs are just added to the end of the table, so instead of a
generation counter, it's sufficient to just keep track of the number of entries
that we've populated in each table.
FixupDispatchTable now just populates any new table entries, starting after
whatever the last populated index was. It also now fetches the function names
from GLAPI instead of using its own list.
Removed CreateGLAPITable. FixupDispatchTable will allocate the table if
necessary. Since it doesn't need to treat static and dynamic stubs differently,
initializing a new empty table is no different than updating an existing table.
Also added a check for a calloc failure in __glDispatchCreateTable and
FixupDispatchTable, which will now propogate that error up to the caller.
Removed _glapi_init_table_from_callback, and the script that generates it.
Instead, libGLdispatch.so just iterates over the stub list to find the name for
each function.
Also removed the struct definition for _glapi_table, since it's only used in
_glapi_init_table_from_callback. Everything else just treats it as an array
of pointers.
Changed the public_stubs array so that it includes the full name of each
function, including the "gl" prefix, so that it can pass that name to the
vendor's getProcAddress callback.
Changed stub_find_by_slot to use an array lookup instead of a linear search.
The mapi_stub struct now just keeps a pointer to the name of the stub, for both
static and dynamic stubs.
Removed the public_string_pool variable. Instead, the public_stubs array
has the function names inline.
Rewrite the x86 TSD dispatch stubs so that they go through the GOT and PLT
tables to look up _glapi_Current and _glapi_get_current, instead of using
absolute addresses for them.
Fixes https://github.com/NVIDIA/libglvnd/issues/108
Fix the generated code for the x86 TLS dispatch stubs.
Update the x86 TLS stubs to use the same common code as the rest of the x86 and
x86-64 entrypoints.
Fixes https://github.com/NVIDIA/libglvnd/issues/18
Add a test for switching between different contexts across multiple vendors.
The new test also checks libEGL's recovery when a vendor's eglMakeCurrent
fails.
The EGL dummy vendor will now keep track of the current context, so that we
can test whether eglMakeCurrent calls get passed through correctly.
Also added a command to force an eglMakeCurrent call to fail, and to fetch the
the current context from directly from a vendor library.
Added a test for EGL_EXT_device_enumeration and EGL_EXT_platform_device, plus
dispatching to an EGL extesnion function based on an EGLDeviceEXT handle.
Added a test for eglGetProcAddress and dispatching for EGL and GL functions.
Added three EGL extension functions to the EGL dummy vendor, to test
dispatching extensions by display, device, and current context.
Added a simple implementation of eglCreateContext, eglDestroyContext, and
eglMakeCurrent, and glGetString.
Added two dummy libraries for EGL. They both use the same code, but each one
has a name string that can be used to check which vendor something is
dispatched to.
The dummy library is still incomplete, but more functions will be add later
along with more tests.
The test just creates an EGLDisplay using a dummy platform type, and then
checks to make sure that the display dispatches to the correct vendor library.
Also added a script to set up the test environment, and a file for common
functions and variables for EGL tests.
testglxqueryversion will now call XQueryExtension to check whether the server
supports the GLX extension. If it doesn't, then it will skip the test instead
of reporting it as a failure.
https://github.com/NVIDIA/libglvnd/issues/93
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
Change the assembly template arrays for ARMv7 to use arrays of 16-bit integers
instead of 8-bit.
This removes the need to byte swap them on little-endian systems.
Added a variation of testglxgetprocaddress that doesn't pre-load the vendor
library. This forces it to generate a GLX entrypoint at runtime for
glXExampleExtensionFunction.
In testglxgetprocaddress.c, added a call to glXGetClientString so that it will
load the vendor library without having to pre-load it.
Rewrite testglxgetprocaddress to remove the PROC_DEFINES and CHECK_PROC macros.
Aside from being easier to deal with in the debugger, breaking up the
CHECK_PROC macro will be necessary to add test coverage for the GLX stub
generation.
When libGLX.so selects a vendor libray for an X screen, it will look for an
environment variable __GLX_FORCE_VENDOR_LIBRARY_<N>, where <N> is the screen
number.
This is mainly for testing and debugging. It allows unit tests to force
different vendors on different screens, and it allows tests to avoid preloading
the dummy vendor library.
Add a new unit test, testpatchentrypoints_gldispatch. It calls into
libGLdispatch directly instead of going through GLX or EGL, and it tests
patching and unpatching between multiple vendor libraries.
Rewrote the x86-64 assembly for the entrypoint patching tests. It now uses
absolute memory addresses instead of RIP-relative, so it can work even if the
variable that it's supposed to update isn't within +-2GB of the function.
Added a separate script glxenv.sh for the common environment variables used by
the other GLX tests.
Removed the testx11glvndproto and testglxnscreens tests, since both of them
depend on the x11glvnd X extension, which is no longer used.
Removed the unused GLX_dummy_copy stuff from the GLX_dummy makefile. Also
removed the COMMON_* variables, since they're only ever used once each.
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.
In __eglGetEGLDispatchAddress, initialize the addr variable to NULL. Otherwise,
it could end up being uninitialized if there are no vendor libraries loaded.
Fixes https://github.com/NVIDIA/libglvnd/issues/96