Commit graph

116 commits

Author SHA1 Message Date
Brian Nguyen 09126a72d5 Re-implement libGL such that ELF symbol filtering is optional
Unfortunately, glibc has a bug where dlopening a shared library with
DT_FILTER or DT_AUXILIARY ELF headers can cause the application to
segfault (see https://sourceware.org/bugzilla/show_bug.cgi?id=16272).
Hence, for now, we can't rely on ELF symbol filtering to implement the
libGL compatibility library for libGLdispatch and libGLX.  This change
re-implements libGL such that this is no longer necessary, by building
in the glapi static dispatch stubs and implementing thin wrapper
functions around GLX entrypoints.

- Rename getCachedProcAddress() to __glXGetCachedProcAddress() and give
  this public visibility.  This is used by the libGL wrapper library to
  retrieve GLX entrypoints at load time.

- Link libGLX with the -Bsymbolic flag so __glXGetCachedProcAddress()
  avoids referencing functions in the libGL wrapper library when libGL
  and libGLX are both loaded.

- Replace the hand-coded no-op definitions in libglxnoopdefs.h with
  a spec file, glx_funcs.spec, and a simple Perl script, gen_stubs.pl,
  which parses the file and generates no-op functions as well as
  pass-through functions that are used by libGL.

- Restructure GLdispatch/vnd-glapi/mapi/entry.c such that the pure C
  fallback code is in its own header, entry_pure_c.h.  In each of the
  entry_*.h headers, separate code not related to implementing the
  static dispatch stubs into an "#if !defined(STATIC_DISPATCH_ONLY)"
  block.

- Give u_current (which is #defined as _glapi_Current or
  _glapi_tls_Current depending on the thread storage model used) public
  visibility so it can be referenced from outside of libGLdispatch.so.

- When building libGL, include GLdispatch/vnd-glapi/mapi/entry.c in the
  sources, and define STATIC_DISPATCH_ONLY so that only the static
  entrypoints are compiled.  Remove the -Wl,--auxiliary flags from
  Makefile.am.

Bonus: fix "make distcheck" by adding GLdispatchABI.h to noinst_HEADERS.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-12-04 10:08:15 -08:00
Brian Nguyen c04905563a Remove superfluous glapi AM_CONDITIONAL()s
These various conditionals are always true or false and hence can be
removed.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-11-25 15:32:11 -08:00
Brian Nguyen d076d45358 Downgrade required autoconf to 2.63 to allow building on RHEL 6.4
This requires adding ACLOCAL_AMFLAGS variable to the toplevel
Makefile.am which includes the m4 subdirectory since Autotools won't
necessarily check the contents of AC_CONFIG_MACRO_DIR() (see [1] for
more info).

[1] http://www.gnu.org/software/libtool/manual/html_node/Invoking-libtoolize.html

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-11-25 13:30:32 -08:00
Aaron Plattner c552b7173c [build] make mapi a subdirectory of vnd-glapi
Currently, the GLdispatch makefile recurses into the mapi/vnd-glapi
subdirectory, which then uses files out of its parent directory.  This makes it
difficult to include the mapi directory in the dist tarball because just
including it in EXTRA_DIST makes it pick up the generated Makefile in addition
to the checked-in source files.

Instead, exchange the two directories so that mapi is a subdirectory of
vnd-glapi and the former is included wholesale with EXTRA_DIST.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-09-27 03:11:51 -07:00
Aaron Plattner b7561d880d [build] don't try to create src/GLdispatch/mapi makefiles
The build doesn't recurse into these directories, so their Makefile.in files
aren't propagated to the dist tarball.  That makes configure fail because it
tries to read those files to generate Makefiles in those directories.

Since these directories aren't built, don't try to create Makefiles in them.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-09-26 23:50:04 -07:00
Aaron Plattner 4010fadf5c [build] enable silent rules by default
Automake still defaults to verbose output unless you explicitly request that the
silent rules be enabled by default.  It's possible to only enable the silent
rules on versions of automake that actually support it, but automake 1.11 has
been around for long enough that it seems easier to just bump the minimum
required version.

Add the boilerplate required to turn on the silent rules by default.  They can
still be disabled by passing --disable-silent-rules to configure or by passing
V=0 on the make command line.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
2013-09-26 23:10:18 -07:00
Aaron Plattner 4ecfeb2a99 [build] reorder SUBDIRS to only recurse once
Currently, both GLX and GLdispatch recurse into src/util/trace.  This causes
problems for parallel make, and breaks distclean because the first recursion
into src/util/trace deletes the Makefile, causing the second recursion to fail.

Instead, recurse directly into util from src/Makefile.am, putting it ahead of
both GLX and GLdispatch in SUBDIRS.  This means that you can't just go into
src/GLX and type make, but it fixes parallel builds and distclean.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2013-09-26 16:17:11 -07:00
Brian Nguyen b3f7cbc3e0 [tests] Add a GLX_dummy dummy vendor library
This vendor library will be loaded by the API library in various
subtests in the test suite, and will implement the bare minimum
needed to verify features and code paths in the API library. This
includes creating a fake GL "context", making current to the
"context", and calling some GL functions.
2013-08-26 11:03:43 -07:00
Brian Nguyen 42589ec4c5 [tests] Add basic test infrastructure
This adds build infrastructure for unit testing the API library
using the serial test harness. TODO: this should be replaced with
the parallel test harness, as the automake documentation says the
serial harness is deprecated.

The first and last tests to be run are scripts to initialize the test
environment (an X session with a special -modulepath argument and
xorg.conf file to pick up x11glvnd) and tear it down after all unit
tests are run.

This also adds a placeholder directory for a fake vendor library
called "GLX_dummy", to be implemented later.
2013-08-26 11:03:43 -07:00
Brian Nguyen e6da529d16 Add libGL and libOpenGL filter libraries
libOpenGL is a filter library on libGLdispatch which only exports the
core GL 1.x-4.x entrypoints.

libGL is a filter library on libGLX and libGLdispatch which only exports
the core GL 1.x-4.x entrypoints and GLX 1.4 entrypoints. This is a
backwards compatibility layer for legacy apps which link against the old
libGL.so ABI.
2013-08-26 11:03:43 -07:00
Brian Nguyen 873faf57b0 [GLdispatch] Build mapi
- 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.
2013-08-26 11:03:42 -07:00
Brian Nguyen 3eb00015de Add x11glvnd X11 extension
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).
2013-08-26 11:03:42 -07:00
Brian Nguyen 8b3953b2f7 Add GLdispatch DSO
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.
2013-08-26 11:03:42 -07:00
Brian Nguyen 8dad6e57f8 Implement glvnd_pthread
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.
2013-08-26 11:03:41 -07:00
Brian Nguyen 4ee8d21ae6 Implement tracing
This implements a small tracing convenience library for debugging
purposess.
2013-08-26 11:03:41 -07:00
Brian Nguyen 05e64e91cb Add autotools infrastructure for libglvnd 2013-08-26 10:29:08 -07:00