Commit graph

506 commits

Author SHA1 Message Date
Kyle Brenneman 8b7a44fb6d tests: Expand the unit tests for libGLdispatch.
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.
2017-02-28 16:37:36 -07:00
Kyle Brenneman 4ba5345742 Merge pull request #113 from nwnk/armv7hl
Fixes for armv7.

Fix build failures for the ARMv7 stubs that show up on some compiler versions.
2017-02-09 10:46:23 -07:00
Kyle Brenneman dc16f8c337 Merge pull request #112 from kbrenneman/configure-component-flags
Add configure flags for EGL, GLX, and GLES
2016-12-22 13:05:51 -07:00
Kyle Brenneman 7067ba11c5 configure: Change the description for --disable-gles. 2016-12-22 13:03:40 -07:00
Rob Clark 75946d7135 Treat armv7hl as armv7l 2016-12-14 11:06:05 -05:00
Rob Clark b34d795f70 armv7: make sure asm is compiled in unified syntax mode
The individual stub functions already have .thumb_func but if syntax is
divided the assembler will reject the STUB_ASM_CODE.
2016-12-14 10:53:38 -05:00
Rob Clark 73320e7174 Fix compile errors 2016-12-14 10:53:33 -05:00
Rob Clark b465dc65f6 Print out $host_cpu when undetected, for easier debugging 2016-12-14 10:53:30 -05:00
Kyle Brenneman ca0de36630 Add configure options for the EGL, GLX, and GLES libraries.
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.
2016-12-13 15:45:26 -07:00
Kyle Brenneman 152ba20ff1 tests: Clean up tests makefile.
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.
2016-12-13 15:36:31 -07:00
Kyle Brenneman 480046fa04 Merge pull request #111 from kbrenneman/libegl-platform-detection
Better X11 and Wayland platform detection
2016-12-13 11:42:38 -07:00
Kyle Brenneman 2febabe709 GLdispatch: Remove the __GLdispatchProcEntry list.
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.
2016-12-09 09:57:28 -07:00
Kyle Brenneman 839c97a410 GLdispatch: Remove _glapi_init_table_from_callback.
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.
2016-12-09 09:57:28 -07:00
Kyle Brenneman f544e43468 GLdispatch: Remove public_string_pool.
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.
2016-12-09 09:57:28 -07:00
Kyle Brenneman 9a17198be3 GLdispatch: Fix TEXTREL in the x86 TSD stubs.
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
2016-12-01 12:41:54 -07:00
Kyle Brenneman f9117614be GLdispatch: Fix the x86 TLS stubs.
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
2016-12-01 12:18:47 -07:00
Kyle Brenneman 522c601799 Add support for aarch64.
Add assembly code and stub generation for TSD stubs on aarch64.
2016-11-15 08:36:51 -07:00
Kyle Brenneman 839a33ef43 Merge pull request #110 from kbrenneman/fix-issue-103-eglfini
Remove the remaining calls to the vendor library from __eglFini and __glXFini.
2016-11-09 10:51:45 -07:00
Kyle Brenneman 260a54606c tests: Add a test for EGL_KHR_debug. 2016-11-02 17:03:33 -06:00
Kyle Brenneman 359c99d547 tests: Add a test for eglGetError.
Add a test to check libEGL's error reporting, including errors reported by a
vendor library.
2016-11-02 17:03:31 -06:00
Kyle Brenneman b892485054 tests: Add a test for eglMakeCurrent.
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.
2016-11-02 17:03:29 -06:00
Kyle Brenneman cd186e8479 tests: Add a test for EGL device functions.
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.
2016-11-02 17:03:27 -06:00
Kyle Brenneman 579e0acdb0 tests: Add a test for eglGetProcAddress.
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.
2016-11-02 17:03:18 -06:00
Kyle Brenneman 3e7bba599f tests: Add a basic test for eglGetPlatformDisplay.
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.
2016-11-02 16:37:55 -06:00
Kyle Brenneman 4546879413 tests: Remove init_test_env.sh and fini_test_env.sh.
Without the x11glvnd tests, nothing actually uses anything in the
init_test_env.sh and fini_test_env.sh scripts.
2016-10-31 16:15:29 -06:00
Kyle Brenneman 7fb2537acf EGL: Fix the python command line.
Fix the python command lines so that they use the correct variable name for the
python executable.
2016-10-31 14:56:58 -06:00
Kyle Brenneman 0cea17eb04 Merge pull request #97 from aaronp24/master
Fix genCommon.py with Python 3
2016-10-31 14:42:32 -06:00
Kyle Brenneman 97c4909a61 tests: Skip testglxqueryversion if the server doesn't support GLX.
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
2016-10-28 19:27:31 -06:00
Kyle Brenneman c9378ea943 EGL: Fix an unitialized variable in IsX11Display. 2016-10-27 13:43:39 -06:00
Kyle Brenneman 470fc824a3 Merge branch 'tests-glx-genentry'
Expand the unit tests to test the generated GLX entrypoints.
2016-10-27 13:07:58 -06:00
Kyle Brenneman 31d0c31610 EGL: Add display detection for X11.
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
2016-10-26 18:07:28 -06:00
Adam Jackson 10a4095b33 EGL: Better wayland detection in eglGetDisplay
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.
2016-10-26 18:07:00 -06:00
Kyle Brenneman b78630eebd Merge pull request #109 from aaronp24/fix-execute-bits
chmod -x files that aren't scripts
2016-10-25 17:59:33 -06:00
Kyle Brenneman 8146a979d8 EGL: Don't call into the vendor library from __eglFini.
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
2016-10-25 17:40:53 -06:00
Kyle Brenneman 758b525463 GLdispatch: Don't call into the vendor from __glDispatchForceUnpatch.
In __glDispatchForceUnpatch, don't call the vendor's releasePatch callback,
because the vendor library might have already been unloaded by that point.
2016-10-25 17:32:47 -06:00
Aaron Plattner 996db4f2c2 chmod -x files that aren't scripts
These two files have mode 755, but aren't scripts that should be executed.
Remove their execute bits.
2016-10-25 16:08:35 -07:00
Kyle Brenneman 28867bb659 Merge pull request #105 from kbrenneman/fix-issue-103
Fix a crash in process termination when EGL and GLX are both loaded.
2016-10-25 11:42:35 -06:00
Kyle Brenneman 61bd107cc6 Fix a crash in process termination when EGL and GLX are both loaded.
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
2016-10-24 14:52:27 -06:00
Kyle Brenneman f556baa293 Change the assembly templates for ARMv7 to use uint16_t.
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.
2016-10-18 15:25:21 -06:00
Kyle Brenneman dc95a0eec0 tests: Add a test for generated GLX entrypoints.
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.
2016-10-18 13:46:18 -06:00
Kyle Brenneman 6601edb825 tests: Rewrite testglxgetprocaddress.
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.
2016-10-18 13:46:16 -06:00
Kyle Brenneman a77ce91f37 GLX: Add an environment variable to specify a vendor for a single screen.
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.
2016-10-18 13:46:15 -06:00
Kyle Brenneman a813b56339 tests: Add a more extensive test for entrypoint patching.
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.
2016-10-17 11:12:21 -06:00
Kyle Brenneman dbfaa50bd8 tests: Move the entrypoint patching code into a helper library.
Moved the code for testing entrypoint patching into a helper library so that
it can be used for more than just GLX.
2016-10-17 11:12:21 -06:00
Kyle Brenneman 6bc8902de8 tests: Rename GLX_dummy directory.
Rename the GLX_dummy directory to just "dummy", since the code in it will be
used for non-GLX tests.
2016-10-17 11:12:21 -06:00
Kyle Brenneman fa6a74c03b tests: Some minor cleanup
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.
2016-10-17 11:12:21 -06:00
Kyle Brenneman 1cd6a43122 Factor out some common extension string functions.
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.
2016-10-13 13:22:13 -06:00
Kyle Brenneman 295e5e5769 EGL: Fix an uninitialized variable.
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
2016-10-07 11:08:02 -06:00
Aaron Plattner aa7c576c66 Don't use 'xrange' because Python 3 doesn't have it.
Apparently 'xrange' isn't a thing in Python 3. 'range' does the same thing and
works for both, so use that.
2016-10-06 13:57:42 -07:00
Kyle Brenneman 14f6283166 Increment the package version to 0.2.
Increment the minor version number so that other packages can check if the EGL
interface is available.
2016-09-09 18:00:59 -06:00