Commit graph

309 commits

Author SHA1 Message Date
Kyle Brenneman ec97db7746 Install the public header files.
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.
2016-01-13 16:04:40 -07:00
Kyle Brenneman e5225e3da3 Merge pull request #50 from aaronp24/kde-clientstring-workaround
GLX: Return dummy strings for glXGetClientString(NULL, ...)
2016-01-08 15:12:43 -07:00
Aaron Plattner da090a2e38 GLX: Return dummy strings for glXGetClientString(NULL, ...)
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>
2016-01-08 13:33:46 -08:00
Kyle Brenneman e0e502bbbf Merge pull request #49 from kbrenneman/libglx-fix-glxfbconfig-abi
GLX: Fix GLXFBConfig mapping with multiple displays.
2016-01-06 16:50:23 -07:00
Kyle Brenneman c254ef4ada GLX: Use an assert to check for mismatched handle-to-vendor mappings.
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.
2016-01-06 10:23:32 -07:00
Kyle Brenneman 6d8d0efb3f GLX: Fix a bunch of outdated names.
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.
2016-01-04 15:17:30 -07:00
Kyle Brenneman 5c27a7817f GLX: Don't record the display pointer for contexts and configs.
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.
2016-01-04 15:10:04 -07:00
Kyle Brenneman bedb59a580 GLX: Use separate hashtables for contexts and configs.
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.
2016-01-04 14:55:36 -07:00
Kyle Brenneman 903ea20962 GLX: Remove the screen number from the pointer-to-vendor hashtable. 2016-01-04 13:40:15 -07:00
Kyle Brenneman 45aa814b11 GLX: Remove the screen from the GLXFBConfig map in the ABI.
Removed the screen number parameter from the GLXFBConfig mapping functions in
__GLXapiExports.
2016-01-04 13:20:46 -07:00
Kyle Brenneman 6116a24fec GLX: Remove the screen from the context map in the ABI.
Removed the screen number parameter from the context mapping functions in
__GLXapiExports.
2016-01-04 13:05:09 -07:00
Kyle Brenneman 973174c921 GLX: Add the vendor pointer to the context/config mapping. 2016-01-04 12:52:14 -07:00
Kyle Brenneman 161c6cb649 GLX: Remove the screen from the drawable map in the ABI.
Removed the screen parameter from the drawable mapping functions in
__GLXapiExports.
2016-01-04 12:37:08 -07:00
Kyle Brenneman 164c157ea2 GLX: Remove the screen from the XID mapping.
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.
2016-01-04 12:23:29 -07:00
Kyle Brenneman 83c9a70b7b GLX: Add a pointer to the vendor in the drawable mapping.
This is in preparation for removing the screen number entirely from the config,
context, and drawable mappings in the ABI.
2016-01-04 12:20:53 -07:00
Kyle Brenneman 362c3591aa GLX: Generate errors for invalid GLXFBConfigs.
When dispatching a function based on a GLXFBConfig, generate a GLXBadFBConfig
error if the config is invalid.
2015-12-18 13:28:24 -07:00
Kyle Brenneman 644caa3409 GLX: Generate errors for invalid contexts.
When dispatching a function based on a GLXContext, generate a GLXBadContext
error if the context is invalid.
2015-12-18 13:28:24 -07:00
Kyle Brenneman a627c5d166 GLX: Generate errors for invalid drawables.
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.
2015-12-18 13:27:45 -07:00
Kyle Brenneman 273e11940e GLX: Add a missing lock.
In DisplayClosed, take the mutex for the current context hashtable before
calling UpdateCurrentContext.
2015-12-16 10:47:32 -07:00
Kyle Brenneman e4cdd1431b GLX: Fix a couple deadlocks.
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.
2015-12-09 15:56:36 -07:00
Kyle Brenneman 71c96a71a7 GLX: Fix an error check in glXMakeCurrent.
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.
2015-12-02 11:52:26 -07:00
Kyle Brenneman 2f06c1656b GLX: A couple of minor fixes.
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.
2015-11-23 12:04:39 -07:00
Kyle Brenneman 4038efca1f Implement GLESv1.
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.
2015-11-20 14:44:25 -07:00
Kyle Brenneman c0d9bbf184 Factor out the common makefile code in libGLESv2 and libOpenGL.
Moved the duplicated makefile code for libOpenGL and libGLES to a new
file, entrypoint_common.mk.
2015-11-13 16:23:01 -07:00
Kyle Brenneman 2e8f77c11b Implement GLESv2.
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.
2015-11-13 16:22:42 -07:00
Kyle Brenneman 41c8dc023b Generalize the export list generation scripts.
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.
2015-11-13 16:22:02 -07:00
Kyle Brenneman 31947394c7 libGLdispatch: Enable entrypoint patching for the x86 TSD build.
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.
2015-11-13 11:40:22 -07:00
Kyle Brenneman 7f0ef9eae5 Don't install the unit test dummy vendor libraries.
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.
2015-11-12 10:04:39 -07:00
Kyle Brenneman 97f8039fcd Merge pull request #47 from kwizart/make-dist
Add few missing files and directory for make dist
2015-11-11 12:21:55 -07:00
Kyle Brenneman 63d95dda78 Remove the execute flags from gl.xml and glx.xml.
The XML files are obviously not executable, but the flag was set from when I
copied them from the Khronos SVN repository.
2015-11-11 11:17:56 -07:00
Kyle Brenneman 08f3208a08 libGLdispatch: Update the documentation for entry_get_public.
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.
2015-11-11 10:58:12 -07:00
Kyle Brenneman 0626538361 libOpenGL.so: Only generate the entrypoints that we're going to export.
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.
2015-11-11 10:58:04 -07:00
Nicolas Chauvet 48255183c5 Add few missing files and directory for make dist 2015-11-10 22:37:02 +01:00
Kyle Brenneman 81bbbaeae9 libGLdispatch.so: Fixes for the public stub array.
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.
2015-11-09 09:48:02 -07:00
Kyle Brenneman 746a71dc1a libGLX: Fix a segfault when libGLX can't find a vendor for a screen.
In __glXLookupVendorByScreen, check to make sure the vendor returned by
__glXLookupVendorByName is not NULL before trying to dereference it.
2015-11-04 16:52:08 -07:00
Kyle Brenneman e356f84554 libGLdispatch: Remove the old code generation scripts.
The old scripts have been replaced with the scripts under src/generate,
so the old ones aren't used or needed anymore.
2015-10-30 16:31:38 -06:00
Kyle Brenneman fd5c500b4c libGLdispatch: Don't export the OpenGL entrypoints.
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.
2015-10-30 14:58:37 -06:00
Kyle Brenneman e6c4fb579a libGL/libGLdispatch: Added missing entrypoints.
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.
2015-10-30 14:58:12 -06:00
Kyle Brenneman 9796473c98 libGL: Add entrypoint stubs for GLX extension functions.
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.
2015-10-30 14:57:29 -06:00
Kyle Brenneman da1b8075b0 libOpenGL: Add a script to generate an export list for libOpenGL.
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.
2015-10-30 14:54:31 -06:00
Kyle Brenneman f1c8b6049d libGLdispatch: Add new code generation scripts.
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.
2015-10-30 14:54:09 -06:00
Kyle Brenneman 07ee773318 libGLX: Change ABI to support glXGetContextIDEXT.
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.
2015-10-26 16:01:44 -06:00
Kyle Brenneman e4e60c407d libGLX: Add support for GLX_EXT_import_context.
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.
2015-10-22 10:39:31 -06:00
Kyle Brenneman d568f63e9c libGLX: Add support for reporting X errors.
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.
2015-10-19 15:19:36 -06:00
Kyle Brenneman 745f5cf35f libGLX: Query the GLX extension when first initializing a display.
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.
2015-10-14 11:21:40 -06:00
Kyle Brenneman a511f3eccb libGLX: Don't leak __GLXAPIState structs.
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.
2015-10-07 19:07:21 -06:00
Kyle Brenneman a924afad34 libGLdispatch: Add a void* parameter to the getProcAddress callback.
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.
2015-10-01 15:24:18 -06:00
Kyle Brenneman 735de93053 Update the readme file.
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).
2015-09-30 13:31:32 -06:00
Kyle Brenneman 38e9f8fb40 libGLX: Remove the GLX 1.4 functions from the ABI.
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.
2015-09-25 14:29:14 -06:00
Kyle Brenneman 3d43071413 GLdispatch: Rename _glapi_get_dispatch and _glapi_set_dispatch.
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.
2015-09-23 12:32:38 -06:00