FixupDispatchTable() does the work of iterating through the list of new
pending entrypoints and querying the vendor library assigned to a
dispatch table for the appropriate function address.
FindProcInList() is used to check for duplicate procs in the tracking
lists.
This is used for fixing up all current dispatch tables whenever a thread
calls GetProcAddress() on a function which has never been seen before by
GLdispatch. The fixup itself should be threadsafe since the dispatch
lock will be taken around all accesses to this list, and actual GL calls
won't be made to the newly-GetProcAddress()'ed function since the
address for this function hasn't been returned to the application yet.
Introduce two lists for tracking dynamic dispatch stubs: newProcList and
extProcList. newProcList contains stubs which were generated by a
getProcAddress call but not assigned a prototype from a vendor, and
extProcList contains stubs which have been assigned a prototype but may
still need the vendor's implementation to be plugged into the dispatch
tables.
Also introduce a generation number which is an attribute of both
dispatch stubs and dispatch tables, and a global variable,
latestGeneration. Each time __glDispatchGetProcAddress() generates a new
dispatch stub, latestGeneration is incremented and assigned to the new
dispatch stub. Dispatch tables with a generation number less than
latestGeneration need to be fixed up with functions from the extProcList
whose generation number is greater than the dispatch table's number.
After the fixup is complete, the dispatch table's generation is updated
to latestGeneration.
This also requires we track current dispatch tables globally; this will
be done in a subsequent change.
Link against glapi to get the required symbols we need.
- Replace hard-coded mapi and mesa paths in mapi makefiles with the
autoconf variables MAPI_PREFIX and MAPI_MESA_PREFIX
- In mapi_abi.py, create a new vnd-glapi printer which provides a
statically-linked glapi (implemented using mapi) with public symbols
for consumption by libGLdispatch.
- Create a vnd-glapi subfolder and makefile for building glapi in this
mode, copied from shared-glapi. The Makefile.am (not SConscript) has
been modified to build glapi_mapi_tmp.h using the vnd-glapi printer.
- Fix top-level makefile to call into the mapi/vnd-glapi subdirectory,
and configure.ac to generate the makefile at bootstrap time.
The MESA API module, mapi, and its corresponding GL submodule, glapi,
will be used by GLdispatch for implementing dynamic and static GL stub
generation and management of core GL dispatch tables.
This fills in currently unimplemented functions for packing protocol
in the client, and retrieving mappings in the server.
- XID -> screen mappings are performed by running
dixLookupResourceByType() on the appropriate resource lists. A
callback which GLX can plug into allows for the registration of
additional resources to do XID -> screen tracking (e.g. GLX
drawables).
- screen -> vendor mappings are saved in XGLVendor's screen privates
when the extension is loaded
Implement the server-side dispatching function for routing an XGLVendor
request to the right proc, but don't implement the actual lookup
functionality, yet.
This will be used to handle the corner case when a drawable XID is
passed into the API library which belongs to an X window or otherwise
has never been seen before by the process, by providing a way to lookup
which screen the corresponding drawable belongs. This still is racey
since we can't guarantee a different process won't free the XID and
cause it to be recycled as a handle for a different resource after the
lookup, but better than not being able to figure out the mapping at all.
This extension also solves the less-difficult problem of mapping a
screen to a vendor name (though it may make more sense to at some point
directly map drawables to a vendor to better support render-offload
scenarios).
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.
This implements thin wrappers around libGLdispatch which allow vendors
to manage their own dispatch tables. See documentation in the interface
header file libglxabi.h for more details.
Add a new header file, GLdispatch.h, which defines an API for
window-system libraries such as libGLX to manage core GL dispatch tables
as well as TLS. Refactor the __GLXAPIState to be derived from
__GLdispatchAPIState, make __GLXvendorInfo::glDispatch type
__GLdispatchTable, and implement make current/get current functionality
using this API.
At some point this API will be implemented in a shared library used by
both libGLX and libEGL.
Set the __glXDispatchNoopPtr statically to the __glXDispatchNoop
dispatch table, defined in libglxnoop.c.
Define no-op GLX 1.4 templates in libglxnoopdefs.h, which is included by
libglxnoop.c. We do this instead of defining the no-op functions
directly because these functions will also be needed by the libGL filter
library. To facilitate code sharing, these templates use GLXNOOP and
NOOP_FUNC() macros to respectively define the function qualifiers and
prefix (e.g. "glX") of each no-op function.
This function is an implementation of the fetchDispatchEntry export,
which is called by vendor-implemented GLX dipsatchers to fetch a
dispatch table entry given a logical dispatch table index.
This change also implements the logic for assigning dispatch table
indices to GLX entrypoints at glXGetProcAddress() time. The dynamic
dispatch table is actually a hashtable which uses the "index" as a key,
and not a flat array, to prevent wasted memory usage from sparse
dispatch tables. Since GLX entrypoints are generally not
performance-critical this should be fine.
This implements __glXLookupVendorByName(), which is responsible for
checking a hash table for existing loaded vendors with the given name,
and loading the vendor with that name if no existing vendors are found.
This also implements __glXGetGLXDispatchAddress(), which iterates
through this hash table checking whether each loaded vendor supports
dispatching to the given GLX entrypoint.
This function, which looks up a vendor given a screen number, is used
by several helper functions which look up core GL and GLX dispatch
tables given a screen number, and directly by the API library's make
curent proc. This relies on the (still unimplemented) function
__glXLookupVendorByName().
This also doubles as a way to store addresses of locally-exported GLX
functions; we use a pthread_once() callback to initialize the table
with these addresses.
libglxmapping.c implements functions needed for libGLX to map function
calls to vendors for dispatching.
libglxnoop.h contains a pointer to a no-op dispatch table.
These will be re-implemented in a later change.
This is a wrapper library around libpthread which implements
single-threaded fallbacks in case the API library is loaded in an
application which does not link against pthreads.
This makes use of a (still unimplemented) helper function called
MakeContextCurrentInternal() to actually perform the required API
library work for make current.
- libglxabipriv.h: This is a simple wrapper around libglxabi.h which
defines the static dispatch table to be the same as the set of
functions exported by the vendor (they could potentially differ).
- libglxcurrent.h: This defines a current "API state" struct which
encapsulates the API library's knowledge of the current display,
read/draw drawables, dispatch tables, and vendor (owning the current
context). The glXGetCurrent*() functions are implemented by
retrieving various fields from this API state.
- libglxmapping.h: This defines a "vendor info" struct which contains
information about a loaded vendor. It also provides accessor functions
for retrieving the dispatch table given a screen, and functions for
adding/removing mappings from various keys (Context, FBConfig,
Drawable) to screens.
- libglx.c: Replace the dummy GetStaticDispatch() function with calls to
the API in libglxmapping.h to retrieve the right dispatch table.
Add a makefile to build libGLX.
Update dispatch functions for each of the GLX 1.4 entrypoints
as well as stubs for glXGetProcAddress() and glXMake{Context,}Current()
to use the new vendor library ABI.