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.
KDE calls glXGetClientString with a NULL dpy argument, which crashes in the call
to XScreenCount(dpy). Work around it by explicitly checking for this and
returning some static strings.
Note that one oddity is that querying the GLX_VERSION with a NULL dpy will
return the maximum version supported by libglvnd, but specifying a display will
return the maximum supported by any vendor on the display (up to libglvnd's
supported maximum).
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
In AddVendorPointerMapping and AddVendorXIDMapping, if there is an existing
mapping, then add an assert that the new vendor library matches the old one.
Handles have to map to at most one vendor, so if we get two different vendors
then there's a bug either in libGLX or in the vendor libraries.
Renamed a bunch of structures and functions to reflect the fact that libGLX
maintains mappings of most objects directly to vendors now, not objects to
screens.
Remove the Display pointer from __GLXscreenPointerMappingHash. It's no longer
needed for anything in libGLX.so. Dispatch functions can find a vendor library
given only the GLXContext handle itself, so functions like glXGetContextIDEXT
don't need the display either.
libGLX now uses a separate hashtable for mapping GLXContext and GLXFBConfig
handles to vendor libraries.
Updated the ABI documentation to define requirements for GLXContext and
GLXFBConfig values, to ensure that there aren't ever any duplicate handles
between vendor libraries.
libGLX now only keeps track of the vendor library for each drawable, not the
screen number.
__glXVendorFromDrawable will now always return -1 for the screen. The screen
parameter will be removed in a later change.
When dispatching a function based on a GLXDrawable, generate an X error if the
drawable is invalid.
Added a helper function CommonDispatchDrawable to handle initialization,
looking up a vendor for a drawable, and reporting an error if it can't find
a vendor.
Removed __glXGetDrawableStaticDispatch, and replaced it with
CommonDispatchDrawable.
Removed the unused function __glXScreenFromDrawable.
Change the current context hash to use a recursive mutex instead of an rwlock.
In __glXLookupDisplay, don't take the lock until after InitDisplayInfoEntry
returns, so that it doesn't try to make any X calls while holding the lock.
If an X error occurs while holding a non-recursive lock, then the error handler
may call exit, which would in turn call __glXFini. That can cause a deadlock if
__glXFini tries to take the same lock.
In CommonMakeCurrent, if the new context is NULL and the drawables are not
None, then it should always generate a BadMatch error. But, if the old context
was NULL, then it would return before checking for the BadMatch error.
In MergeVersionStrings, deal with a zero return value from glvnd_asprintf. Zero
is technically a successful return value from glvnd_asprintf, even though none
of the format strings could produce it.
Remove a bit of dead code from AtomicDecrementClampAtZero. The only way for the
if(newVal < 0) branch to be taken is if (oldVal <= 0), which it can't be at
that point.
Added a Makefile to build libGLESv1_CM.so. It's copied and adapted from the one
for libOpenGL.so.
The GLESv1 library currently exports all of the core functions in gl.xml for
GLES version 1.0.
Added a Makefile to build libGLESv2.so. It's copied and adapted from the one
for libOpenGL.so.
The GLESv2 library currently exports all of the core functions in gl.xml for
GLES versions 2.0 through 3.2, inclusive.
In genCommon.py, change getLibOpenGLNamesFromRoots so that it accepts a target
parameter. Defined separate targets for each library, including libGLdispatch.
gen_libOpenGL_exports.py now takes a target parameter just like
gen_gldispatch_mapi.py does.
This is in preparation for adding function lists for the libGLES libraries.
Rewrote the x86 TSD stubs to follow the same pattern and use the same common
functions as the x86-64 stubs.
Aside from being shorter and simpler with less code duplicaiton, this will
allow entrypoint patching to work in the x86 build.
Fixed some errors in the entrypoint patching in the unit tests. The
libGLX_dummy.so library was patching in PC-relative addresses for the MOV
instructions, but those instructions expect absolute addresses.
Change the unit test makefile to use check_LTLIBRARIES instead of
lib_LTLIBRARIES so that the dummy vendor libraries aren't included in a
"make install".
Add a -rpath option to libGLX_dummy and libGLX_patchentry flags to force
libtool to actually create the .so files for them. Otherwise, it just creates
static libraries.
Add a documentation comment to entry_get_public, and change the name of the
parameter to indicate that it takes an array index instead of a dispatch table
slot.
gen_gldispatch_mapi.py now takes an extra parameter to specify which library
it's building, so that it can generate the correct function list for that
library. For libOpenGL.so, it will only generate the functions that it's going
to export.
Updated the makefiles for libOpenGL.so, libGL.so, and libGLdispatch.so to
generate the correct set of entrypoints for each library.
Moved the code to figure out the libOpenGL.so function names to genCommon.py.
Fix a couple of places that assume that the public stub array (as defined in
entry*.c) is in the same order as the dispatch table.
stub_get_addr will now calculate the index of the stub instead of assuming that
the slot and index are the same.
In stubRestoreFuncsInternal, it will run through the length of the public_stubs
array instead of assuming that the array is of length MAPI_TABLE_NUM_STATIC.
This will allow us to remove all the entrypoints in libOpenGL.so that we're
not going to export.
Added an export list for libGLdispatch.so, so that it doesn't export the OpenGL
entrypoints.
The OpenGL entrypoints should only be exposed through libGL.so or libOpenGL.so,
not through libGLdispatch.so.
Added two additional XML files which contain additional GL and GLX functions
that are exported from existing libGL.so implementations but are missing from
the Khronos XML files.
Adjusted the scripts so that they can take a list of XML files instead of just
one.
Added a new script to generate the GLX entrypoints in libGL. The new script
uses Khronos's glx.xml file for a function list.
Checked in a copy of Khronos's glx.xml, from revision 32184.
Added the gen_libOpenGL_exports.py script, which will generate an export list
for building libOpenGL.so.
With this, libOpenGL.so will only export OpenGL core functions up through
OpenGL 4.5.
Add new scripts to replace the GLAPI code generation scripts, using the
Khronos gl.xml file.
All of the scripts are rewritten from scratch, but intended to produce similar
output files to the original scripts:
gen_gldispatch_mapi.py replaces mapi_abi.py, originally from Mesa's mapi_abi.py.
gl_inittable.py and gl_table.py replace the scripts of the same name in
GLdispatch/vnd-glapi/mapi/glapi/gen. Both are originally derived from
Mesa's gl_gentable.py and gl_table.py.
Checked in a copy of Khronos's gl.xml, from revision 32184.
Added a typedef for GLDEBUGPROCKHR to the scripts that need it, so that the
GLES versions of GL_khr_debug will compile.
libGL.so and libOpenGL.so now export the full set of OpenGL functions,
including any extensions.
Changed __GLXapiExports::vendorFromContext so that it only takes a GLXContext
parameter as input, and returns the display, screen, and vendor for the
context.
This is needed to support a dispatch function for glXGetContextIDEXT, since it
only takes a GLXContext handle, not a display.
In libglxmapping.c, the __GLXscreenPointerMappingHash struct now keeps the
display pointer along with the screen number.
Also added an error check for GLXFBConfigs to make sure that the display passed
from the caller matches the recorded one.
Added dispatch functions to libGLX for glXImportContextEXT and
glXFreeContextEXT, since both of them are difficult to implement as a dispatch
function from a vendor library.
Since glXImportContextEXT doesn't take any parameters that directly specify a
screen, it will query the server manually to figure out a screen number.
libGLX will now report any X errors that it generates directly, instead of
relying on a vendor library to report them.
For simply reporting errors, the notifyError callback in every vendor library
is functionally identical, so there's no reason to require every vendor to
implement it.
As a notification, it falls apart in glXMakeContextCurrent, which could have
two different vendor libraries if the drawables are on different screens. In
that case, libGLX has to arbitrarily pick one vendor to notify.
Add a __glXSendError function to libglx.c (based on the same function from
Mesa) to report X errors.
The __GLXapiImports::notifyError callback no longer has to report the X error.
It's mostly a notificaiton, although it returns a boolean value to tell libGLX
whether to report or ignore the error.
In glXMakeCurrent/glXMakeContextCurrent, it will report an error to whatever
vendor library owns the current context (if any), instead of the vendor
libraries for the two drawables. The rest of the function looks to the context
to select a vendor, and the old context is the only one that's valid in this
case.
libGLX will now call XQueryExtension to check the GLX extension the first time
it sees a display.
Add the GLX opcode and error base to __GLXdisplayInfo.
libGLX only gets a callback at thread termination if it has a current context.
If there isn't a current context, then it will leave the thread's __GLXAPIState
in the hashtable until teardown.
Now, libGLX will only keep a __GLXAPIState when it has a current
context. When glXMakeCurrent is called to release the current context, it will
free the __GLXAPIState.
Removed the hashtable for keeping track of the __GLXAPIStates and replaced it
with a linked list.
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.
Updated a couple of places that were out of date.
Removed the TODO section, since the remaining items on it are tracked on
Github's issue tracker instead (#44 and #45).
Removed the __GLX14EntryPoints structure from the vendor library ABI. Instead,
libGLX will use the getProcAddress callback to look up each function after
loading the library.
Moved the contents of __GLXvendorCallbacks into __GLXapiImports.
Changed __GLXdispatchTableStatic to be a separate struct from __GLXapiImports.
It now contains all of the GLX 1.4 function pointers, replacing __GLX14EntryPoints.
Rename the functions _glapi_get_dispatch and _glapi_set_dispatch to
_glapi_get_current and _glapi_set_current.
Aside from better consistency with _glapi_Current and _glapi_tls_Current, this
should make it easier to avoid name clashes with Mesa's GLAPI functions.