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
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
Rename __GLdispatchAPIState to __GLdispatchThreadState, to make it clearer that
the structure contains thread-specific data.
Updated some out-of-date comments.
Added the function pointers for entrypoint rewriting as members of
__GLXapiImports, instead of using a separate __GLdispatchPatchCallbacks
pointer.
Moved the __GLdispatchPatchCallbacks struct to GLdispatch.h.
Two header files (libglxabi.h and GLdispatchABI.h) are public -- intended to be
used by vendor libraries, while the other headers are all internal to libglvnd.
Move the public header files to a new directory, include/glvnd.
Add a makefile so that the public headers are installed by make install.
The getProcAddress callback that libGLdispatch uses to populate the dispatch
table now takes an extra parameter, which contains arbitrary data used by the
callback.
This allows much better flexibility in a how window system library populates a
dispatch table.
Removed __glDispatchGetOffset and __glDispatchSetEntry from libGLdispatch.
Neither one is used anywhere, and the dispatch offsets should be an internal
detail of libGLdispatch.
Removed the mutex from stub_find_dynamic. Anything that calls that function
should already be holding the GLdispatch lock.
Also removed the __GLdispatchGetOffsetHook, since nothing uses it anymore.
Move the vendorID and dispatch members from __GLdispatchAPIState to
__GLdispatchAPIStatePrivate.
How those variables are tracked and used is an internal detail of
libGLdispatch, so they shouldn't be part of the public interface.
__GLdispatchAPIState now has a pointer to an opaque structure, to be used for
arbitrary private data.
This will allow later versions of libGLdispatch to add data for each API state
without changing the binary interface to libGLX.
The struct is mostly empty, but later changes will add more to it.
__glDispatchMakeCurrent now fails if the current thread already has an API
state.
This removes the complication of dealing with switching directly from one vendor
to another, and makes it easier for __glDispatchMakeCurrent to avoid any side
effects if it fails.
Add a version number for the interface between libGLX and libGLdispatch, which
libGLX checks during initialization.
The interface between libGLX and libGLdispatch can and should be a stable ABI,
so that it's more resiliant to version mismatches if they come from different
packages or installers.
The version number is mainly a sanity check in case some future version of
libGLdispatch does change the interface.
Remvoved the context member of __GLdispatchAPIState, and instead added a new
currentContext member to __GLXAPIState.
libGLdispatch only needs the API state pointer, not the window system's context
handle.
This also removes the ill-defined case where a thread could have a current API
state but not a current context.
The "id" member of __GLdispatchAPIState isn't used anywhere in libGLdispatch,
so it doesn't need to be part of libGLdispatch's interface.
Instead, libGLX now stores the thread ID in __GLXAPIState::tid.
Added a pointer to a callback function __GLdispatchAPIState to notify the
window system library of thread termination.
Removed tsdContextKey from libglx.c. It now uses the API state stored in
libGLdispatch and the callback function in __GLdispatchAPIState instead.
libGLX will now free the __GLXAPIState struct for a thread when the thread
terminates, instead of waiting until __glXAPITeardown.
Fixes issue #35
Add a glvnd_key_t key to GLdispatch.c to hold the current API state.
__glDispatchGetCurrentAPIState and __glDispatchGetCurrentContext are now normal
exported functions instead of wrappers around _glapi_get_current.
Removed _glapi_get_current, _glapi_set_current, _glapi_get_context,
_glapi_set_context, and their associated functions in u_current.c.
Removed the U_CURRENT_* constants and replaced them with the corresponding
GLAPI_CURRENT_* constants.
Removed the GLAPI_CURRENT_* enums except for GLAPI_CURRENT_DISPATCH.
Added a __glDispatchCheckMultithreaded function to tell libGLdispatch to check
for multiple threads.
libGLX will now check for a second thread in __glXThreadInitialize.
When ThreadSafe is true, u_current_get_index no longer returns a stale value
from u_current.
__glDispatchFini() is called by a GLdispatch client to clean up
GLdispatch-internal state when the client is done using GLdispatch
functionality.
__glDispatchReset() is called by a GLdispatch client to determine
whether fork recovery is needed, and handle the fork if necessary.
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
Modify __glDispatchMakeCurrent() to take a pointer to the patch
callbacks for the vendor library whose context is about to be current.
Implement GLdispatch.c:PatchEntrypoints() and helpers. This contains
the logic for determining whether it is safe to patch entrypoints, and
using the provided vendor callbacks to actually do the entrypoint
patching. Call this from __glDispatchMakeCurrent() with the provided
patch callbacks.
Also implement GLdispatch.c:CurrentEntrypointsSafeToUse(), which
determines based on the current vendor ID whether the current top-level
code is safe to use with that vendor. If this check fails, the make
current operation fails.
Allow users to disable entrypoint rewriting functionality by setting the
environment variable __GLVND_DISALLOW_PATCHING=1.
When losing current, also attempt to restore the default libglvnd
entrypoints so other vendors can potentially use them.
This allows vendor libraries to potentially overwrite the static
entrypoints of wrapper libraries (such as libGL and libOpenGL) at make
current time, in addition to the main GLdispatch entrypoints.
This implements the notion of a "vendor ID" that is unique to each
vendor library instance loaded in a process. When entrypoint rewriting
is implemented, this will be used by libglvnd to determine whether a
given entrypoint implementation is compatible with a given context, by
comparing the vendor owning the context with the vendor owning the
implementation.
This changes the function prototype of __glDispatchMakeCurrent()
to include the vendorID as an argument, which will be saved off in the
API state, and return a boolean value to indicate whether make current
succeeded.
- Pull GL dispatch callback typedefs into GLdispatchABI.h. This is
a common header which will be shared between the libGLX and libEGL
ABIs.
- Add extern "C" blocks to libglxabi.h and GLdispatchABI.h so these
headers may be used with vendor libraries that are built C++.
- Remove support for auxiliary dispatch table management
(libglxgldispatch.[ch] and __GLdispatchExports). This can be added
back in later on if it proves useful.
- In libglxmappings.c, replace static initialization of glxExportsTable
with one-time runtime initialization of the table.
- In libglxmappings.c, use __glDispatchCreateTable() directly to create
the initial dispatch table.
- In libglxnoopdefs.h, remove unnecessary includes of libglxabipriv.h
and libglxnoop.h.
- Add screen mapping functions to the GLX exports table. Some extension
functions not implemented by libglvnd, e.g. glXCreateContextAttribsARB()
from GLX_ARB_create_context, may need to update the mappings from
context or drawable to screen that are managed by libglvnd in order to
work properly. Additionally, dispatch functions implemented by vendor
libraries for GLX extension functions may want to query these mappings
in order to properly dispatch the call.
- Remove the getDispatchProto() vendor callback. This is not needed by
libglvnd since libglvnd does not support mapping more than one
entrypoint to a single dispatch stub. See GLdispatch.c for the
rationale behind this decision.
- Remove redundant typedefs to prevent build errors.
- Delete the vendorData parameter from the getProcAddress() vendor
callback, which isn't useful if there is no support for more than one
libglvnd dispatch table per context. Add the isClientAPI parameter,
which can be used to distinguish between getProcAddress() requests for
GLX functions versus getProcAddress() requests for client API
functions.
- Remove the "screen" argument from Remove.*Mapping() functions. This
is unnecessary, as the hash key used to lookup the mapping object in
libglvnd's hashtables doesn't depend on the screen (which is the hash
value). It's problematic since in some cases we don't actually know
the value of the screen mapped to by a key.
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
When making current, assign the API state's new context and dispatch table
in GLdispatch rather than GLX. This avoids consistency issues if the API state
is unchanged but the current dispatch or context may have changed.
Update the __glDispatchMakeCurrent() call in
__glXMakeGLDispatchCurrent() to get libglvnd building for now; a later change
will remove libglxgldispatch.c altogether.
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
This replaces the _glapi_tls_{Dispatch,Context} symbols with a single
symbol, _glapi_tls_Current, which references an array of type (void*).
This allows us to easily extend mapi to accomodate additional TLS
entries, which will be necessary for storing current API state and
allowing vendors to utilize TLS entries for their own purposes.
This change is rather messy. It requires modification to both the
dispatch stub generation code and mapi's compatibility #defines in
u_current.h. This could probably be cleaned up in later changes. It's
not clear whether _glapi_{set,get}_{dispatch,context}() are even needed
anymore, but they are kept in place for backwards compatibility and to
keep this change as self-contained as possible.
Move the GLdispatch header file to its own directory in src/GLdispatch,
and build a real DSO that GLX will depend on. In GLdispatch.c, add stub
functions which will later be fleshed out.