]> git.cworth.org Git - fips/log
fips
10 years agoMakefile: Don't install 32/64-bit target if not compiled
Carl Worth [Mon, 7 Oct 2013 22:33:52 +0000 (15:33 -0700)]
Makefile: Don't install 32/64-bit target if not compiled

We are already contionally compiling these, so the right answer is to
only conditionally install them as well.

10 years agoglxwrap: Initialize fips_dispatch when glxMakeContextCurrent is called
Carl Worth [Tue, 27 Aug 2013 20:14:53 +0000 (13:14 -0700)]
glxwrap: Initialize fips_dispatch when glxMakeContextCurrent is called

Previously, we only intitialized fips_dispatch if glxMakeCurrent was
called.  This caused fips to fail for programs that called
glxMakeContextCurrent instead. Both functions are now handled
indentically, (giving fips a clear indication that GLX is being used,
not EGL).

This fixes the failure of fips with Lightsmark 2008.

10 years agodlwrap: Add new dlwrap_dlopen_libfips function
Carl Worth [Mon, 5 Aug 2013 17:23:10 +0000 (10:23 -0700)]
dlwrap: Add new dlwrap_dlopen_libfips function

Previously, two different pieces of fips code (both for dlopen and for
glXGetProcAddress) both needed to dlopen the fips library
itself. However, the two pieces were implemented differently, (one
passed a symbol to dladdr to find a filename to dlopen, the other just
passed NULL to dlsym and hopef for the best).

Make things consistent by having a single, shared implementation in
the new function dlwrap_dlopen_libfips, (and implement it with the
more reliable approach of calling dladdr and then the real dlopen).

10 years agoMakefile: Drop rule for *.cc source files.
Carl Worth [Mon, 5 Aug 2013 17:19:36 +0000 (10:19 -0700)]
Makefile: Drop rule for *.cc source files.

Fips does not include any C++ source code, so it doesn't need this
rule to expand files matching the *.cc pattern.

10 years agoeglwrap: Fix some typos in a comment
Carl Worth [Wed, 3 Jul 2013 00:21:04 +0000 (17:21 -0700)]
eglwrap: Fix some typos in a comment

And drop the text about libGLESv2.so, (functions in libGLESv2 are
already taken care of in glwrap.c).

10 years agodlwrap: Add "libGLESv2.so" to the list of supported wrapped libraries
Carl Worth [Wed, 3 Jul 2013 00:38:28 +0000 (17:38 -0700)]
dlwrap: Add "libGLESv2.so" to the list of supported wrapped libraries

This hooks up libGLESv2 to all of our dlsym machinery. It ensures that
we can intercept any dlsym calls into libGLESv2. It also ensures that
when glwrap looks for underlying, "real", GL functions it will look
into libGLESv2.so if that's the library that the application has
previously dlopened.

This commit fixes the egl-glesv2-dlopen-dlsym and
egl-glesv2-dlopen-gpa tests in the test suite.

10 years agotest: Add 4 tests using EGL and OpenGLESv2
Carl Worth [Tue, 2 Jul 2013 20:07:40 +0000 (13:07 -0700)]
test: Add 4 tests using EGL and OpenGLESv2

These are similar variants to the four existing tests using EGL and OpenGL.

To add these tests we add a new configure-time check to find the
compilation flags for GLESv2. We also drop the set_2d_projection code
which was using glLoadIdentity, glMatrixMode, and glOrtho functions
which apparently don't exist in GLESv2. So common.s and all tests with
custom wrappers are modified to drop these calls.

As with the egl-opengl tests, all new tests except for the dlsym-based
test pass. That's not too surprising since there are so many twisty
paths in trying to get all the dlopen/dlsym stuff to work correctly.

And hurrah for test suites finding bugs!

10 years agoglwrap: Don't hardcode "libGL.so.1" for looking up real OpenGL symbols
Carl Worth [Wed, 3 Jul 2013 00:33:12 +0000 (17:33 -0700)]
glwrap: Don't hardcode "libGL.so.1" for looking up real OpenGL symbols

As preparation for testing using GLESv2 we need to ensure that our GL
wrappers are prepared for an OpenGL implementation in either the
libGL.so.1 library or in libGLESv2.so.2.

When the application is directly linked to an OpenGL implementation,
we don't care about the name at all. In this case, we can simply call
dlsym with RTLD_NEXT to find the real, underlying OpenGL symbols.

But when an application uses dlopen to load the OpenGL library, we
want to carefully call dlsym with a handle for the same library that
the application uses. Previously, the glwrap code was unconditionally
calling dlopen for "libGL.so" and that's not what we want.

Instead, we now have our dlopen wrapper watch for any dlopen of a
library whose name begins with "libGL" and then stashing the returned
handle via a new glwrap_set_gl_handle call. The stashed handle will
then be used by dlsym calls within glwrap.

10 years agoconfigure: Drop broken workarounds for missing pkg-config
Carl Worth [Tue, 2 Jul 2013 19:45:18 +0000 (12:45 -0700)]
configure: Drop broken workarounds for missing pkg-config

Any reasonably-modern system should have versions of things like OpenGL
libraries installed with pkg-config libraries.

Regardless, the checks we had in place here for missing gl.pc files
were untested and obviously not very useful, (they didn't actually
look around anywhere for GL headers nor for GL libraries).

We're better off not even pretending to be able to find things without
pkg-config.

10 years agofips: Fix dlsym wrapper for egl symbols
Carl Worth [Tue, 2 Jul 2013 19:28:03 +0000 (12:28 -0700)]
fips: Fix dlsym wrapper for egl symbols

Previously, fips was failing to provide its own wrapped versions for
functions such as eglMakeCurrent if the application was using dlsym to
locate the symbol. This led to the failure of the egl-opengl-dlopen-*
tests in the test suite.

The root of the problem was that the fips wrapper for dlopen was only
returning the libfips_handle if dlopen was requested for
"libGL.so". But here, we need to also intercept a dlopen for
"libEGL.so" as well.

However, the fix is not as simple as updating dlopen.

Previously, if dlsym failed to find a libfips-specific version of the
symbol of interest it would defer unconditionally to a call to the
real dlsym with a handle dlopened from "libGL.so". That's obviously
the wrong thing for symbols sougth from "libEGL.so". So, now, our
dlopen caches the originally dlopen'ed handles and encodes an index
into its return value so that the final dlsym can reference the
correct handle in order to find its symbol.

This commit fixes the egl-opengl-dlopen-dlsym and
egl-opengl-dlopen-gpa test cases.

10 years agotest: Add remaining three egl-opengl tests
Carl Worth [Tue, 2 Jul 2013 18:53:52 +0000 (11:53 -0700)]
test: Add remaining three egl-opengl tests

In a previous commit message, I had suggested we would be adding five
additional tests here. But unlike GLX, EGL provides only
eglGetProcAddress, (and no eglGetProcAddressARB), so two of the GLX
variants don't apply.

The two dlopen-based tests are currently failing when run under fips,
so once again the test suite has come through and found another bug.

10 years agotest: Add support for EGL-based test, (and one EGL-based test)
Carl Worth [Tue, 2 Jul 2013 00:44:14 +0000 (17:44 -0700)]
test: Add support for EGL-based test, (and one EGL-based test)

For this, common.c now supports a new macro COMMON_USE_EGL which can
optionally be defined by the test before including common.c.

Some aspects of the common.c interface have changed slightly, (the
create_context call is now either create_glx_context or
create_egl_context, and the caller must explicitly call the new
common_make_current call).

This commit adds a single egl-based test, (egl-opengl-link-call),
which is similar to the existing gl-link-call test. This is basically
to ensure that the new code in common.c is functional.

We plan to follow up with egl-opengl variants for the remaining 5
existing gl tests, (and then egl-glesv2 variants for all 6 as well).

10 years agotest: Rename handle-events.c to common.c
Carl Worth [Mon, 1 Jul 2013 18:29:40 +0000 (11:29 -0700)]
test: Rename handle-events.c to common.c

Previously, this C file defined one function
(handle_events). Recently, it acquired a second function
(create_context).

In order to provide a common namespace, these functions are here
renamed to:

common_handle_events
and
common_create_context

so the filename is renamed to match.

Similarly, the HANDLE_EVENTS_GL_PREFIX macro is also renamed to
COMMON_GL_PREFIX.

10 years agoutil-x11: Rework init_window interface to accept XVisualInfo
Carl Worth [Mon, 1 Jul 2013 18:22:17 +0000 (11:22 -0700)]
util-x11: Rework init_window interface to accept XVisualInfo

This is a much more correct way of doing things. Previously, we would select
a visual when creating the OpenGL context, but then use a default visual when
creating a window. This was fragile and would fail if the default visual was
not identical to what we had created.

Now, instead, we pass the selected XVisualInfo to our init_window interface
and call XCreateWindow instead of XCreateSimpleWindow. This guarantees that
the visuals match as required.

10 years agotest: Rename util.c and util.h to util-x11.c and util-x11.h
Carl Worth [Mon, 1 Jul 2013 17:43:50 +0000 (10:43 -0700)]
test: Rename util.c and util.h to util-x11.c and util-x11.h

These utility functions are all specific to the libX11 interface already,
and since we're planning to add some other utility functions soon, (such
as EGL), it will help to not have a too-generic name already used.

While doing this, also split up the interfaces for Display and Window
creation. This will allow us to create the GL context in between to
guarantee that the Window is created with the same visual as the GL
context.

10 years agotest: Add two more tests to the test suite
Carl Worth [Fri, 28 Jun 2013 17:55:59 +0000 (10:55 -0700)]
test: Add two more tests to the test suite

These link directly against libGL, but then use glXGetProcAddress or
glXGetProcAddressARB to locate OpenGL function symbols.

10 years agotest: Reduce code duplication in test-suite programs
Carl Worth [Thu, 27 Jun 2013 22:20:45 +0000 (15:20 -0700)]
test: Reduce code duplication in test-suite programs

All of the test suite programs previously had their own copies of
common drawing code. Now, this code is put into a shared
handle-events.c. Each test program includes handle-events and can
provide its own prefix for called OpenGL functions by first defining
HANDLE_EVENTS_GL_PREFIX.

10 years agoglxwraps: Fix fips for programs that call glXGetProcAddress
Carl Worth [Thu, 27 Jun 2013 21:40:17 +0000 (14:40 -0700)]
glxwraps: Fix fips for programs that call glXGetProcAddress

Previously, fips would work for programs calling glXGetProcAddressARB
but not for programs calling glXGetProcAddress.

Thanks to the recently-added test suite for noticing this bug.

10 years agotest: Add two more tests, (now using glXGetProcAddress instead of dlsym)
Carl Worth [Thu, 27 Jun 2013 21:34:21 +0000 (14:34 -0700)]
test: Add two more tests, (now using glXGetProcAddress instead of dlsym)

One test calls glXGetProcAddress the other calls glXGetProcAddressARB.

And noticeably, the test with glXGetProcAddress fails, so the test
suite has found its first bug.

10 years agotest: Add test using GLX with dlopen and dlsym to find symbols
Carl Worth [Thu, 27 Jun 2013 21:08:39 +0000 (14:08 -0700)]
test: Add test using GLX with dlopen and dlsym to find symbols

Gradually building out the test suite to something useful here.

10 years agofips: Add the beginning of a test suite
Carl Worth [Thu, 27 Jun 2013 20:26:59 +0000 (13:26 -0700)]
fips: Add the beginning of a test suite

So far, there's just one test program. It links against libGL.so and
uses GLX to render a few solid frames. The test suite ensures that it
can be run and that "fips --verbose" actually prints a message.

10 years agofips: Add a -v/--verbose flag.
Carl Worth [Thu, 27 Jun 2013 20:23:55 +0000 (13:23 -0700)]
fips: Add a -v/--verbose flag.

The only real purpose imagined for this for now is to be able to
verify that fips is actually doing something, (for example, if a
program renders less than 60 frames and exits then previous fips would
exit silently).

The --verbose flag will be useful with the upcoming test suite and its
short-lived programs.

10 years agoconfigure: Add pkg-config-based check for libX11
Carl Worth [Thu, 27 Jun 2013 20:22:54 +0000 (13:22 -0700)]
configure: Add pkg-config-based check for libX11

Nothing in fips itself needs to link against libX11, but we'll soon be
adding a test-suite program that needs to be able to.

10 years agoconfigure: Set GL_LDFLAGS and EGL_LDFLAGS in configure script
Carl Worth [Thu, 27 Jun 2013 03:46:40 +0000 (20:46 -0700)]
configure: Set GL_LDFLAGS and EGL_LDFLAGS in configure script

The libfips library doesn't link directly to libGL nor libEGL so
didn't need these flags. But we're adding test programs that do link
to these, so the test's Makefile needs access to these flags.

10 years agoPush final collection of CFLAGS/LDFLAGS from Makefile.config to Makefile.local
Carl Worth [Thu, 27 Jun 2013 01:18:52 +0000 (18:18 -0700)]
Push final collection of CFLAGS/LDFLAGS from Makefile.config to Makefile.local

This makes the final decision more explicit closer to where the flags
are actually being used. This will be helpful as we add other
programs, which can now easily mimic the style of flags collection as
is done for fips.

This also eliminates any potential confusion of FIPS_FLAGS
vs. FINAL_FIPS_FLAGS, etc. The use of "FINAL_" has now been entirely
eliminated.

10 years agoStop processing command-line options at first non-option argument
Carl Worth [Tue, 25 Jun 2013 23:48:13 +0000 (16:48 -0700)]
Stop processing command-line options at first non-option argument

This makes it much easier to pass options to the program being
executed by fips. The options can be passed directly, such as:

fips glxgears -fullscreen

Previous, to this commit, one would have to use a syntax such as:

fips -- glxgears -fullscreen

to prevent fips from trying to interpret the "-fullscreen" argument as
options to fips itself.

10 years agoeglwrap: Add comment describing why we don't lookup into libGLESv2.so
Carl Worth [Mon, 24 Jun 2013 22:49:44 +0000 (15:49 -0700)]
eglwrap: Add comment describing why we don't lookup into libGLESv2.so

A user recently asked me why we didn't perform lookups in
libGLESv2.so, (instead of just libEGL.so). I actually made the mistake
of writing code to do that before I realized the answer.

Adding the answer in a comment here should help me avoid making that
mistake again.

10 years agoEGL: Add wrapper for eglGetProcAddress
Carl Worth [Mon, 24 Jun 2013 22:44:47 +0000 (15:44 -0700)]
EGL: Add wrapper for eglGetProcAddress

If an EGL-using program uses eglGetProcAddress to locate functions, we
want to intercept that to return our own versions of the functions,
(to add out metrics timings, etc.).

If the requested function is not implemented in our library, just
defer to the real, underlying eglGetProcAddress function to find the
symbol.

10 years agoconfigure: Fix configure check to look for egl.h in the correct directory
Carl Worth [Mon, 24 Jun 2013 22:27:50 +0000 (15:27 -0700)]
configure: Fix configure check to look for egl.h in the correct directory

This configure check was broken by looking for GL/egl.h instead of
EGL/egl.h as it should. This failure was masked on any system with an
EGL implementation providing a pkg-config file (egl.pc).

10 years agoPush glBeginQuery/glEndQuery down into metrics.c
Carl Worth [Mon, 24 Jun 2013 22:24:20 +0000 (22:24 +0000)]
Push glBeginQuery/glEndQuery down into metrics.c

The code in metrics.c was already using dynamic dispatch for OpenGL functions.

But the code in glwrap is now, (and cannot since it relies on "real" OpenGL
header files to ensure the wrapped functions have the correct prototypes).

This resulted in link failures since these functions were not called via
dynamic dispatch.

Gix by adding new metrics_counter_start and metrics_counter_stop functions which
call the glBeginQuery/glEndQuery functions via dynamic dispatch.

10 years agofips-dispatch: Completely separate fips-dispatch GL prototypes from GL/gl.h
Carl Worth [Mon, 24 Jun 2013 20:22:59 +0000 (13:22 -0700)]
fips-dispatch: Completely separate fips-dispatch GL prototypes from GL/gl.h

Move the OpenGL prototypes previously in fips-dispatch.h to a new
fips-dispatch-gl.h. The idea here is that any given file should
include only one of GL/gl.h or fips-dispatch-gl.h.

Files that implement libfips wrappers for OpenGL functions include
GL/gl.h to ensure that they implement functions with the correct
prototypes.

Meanwhile, files that call into OpenGL functions at run-time, (such as
metrics.c which calls the various OpenGL query-related functions),
instead include fips-dispatch-gl.h and do not include GL/gl.h. With
this approach, any new calls to OpenGL functions will cause
compilation warnings if the stubs are not also added to
fips-dispatch-gl.h.

10 years agoAdd dynamic dispatch for any calls to OpenGL functions.
Carl Worth [Sat, 22 Jun 2013 00:10:03 +0000 (17:10 -0700)]
Add dynamic dispatch for any calls to OpenGL functions.

Previously, fips code was making direct calls to OpenGL functions,
(such as glGenQueries, glBeinQuery, etc. within metrics.c). Some
OpenGL implementations do not export these symbols directly,
(expecting the application to instead look the symbols up via a call
to glXGetProcAddressARB or eglGetProcAddress).

The new fips-dispatch code added here does precisely that, (and adds
wrapper for both glXMakeCurrent and eglMakeCurrent in order to know
which GetProcAddress function should be called).

The dispatch code follows the model of piglit-dispatch, (available
under the same license as fips). Thanks to Eric Anholt for suggesting
following the same approach as piglit.

10 years agoconfigure: Fix to have compiler warnings enabled while building libfips
Carl Worth [Mon, 24 Jun 2013 20:19:41 +0000 (13:19 -0700)]
configure: Fix to have compiler warnings enabled while building libfips

In commit e42d9f224a4ef2784f8fd43f9f4f5c593a7ddd57 , when the flags
were split between fips and libfips, the warnings flags were
mistakenly applied to both CFLAGS and LDFLAGS of fips. (What was
actually intended was to have the warnings applied to the CFLAGS of
both fips and libfips).

10 years agoTODO: Add some additional items suggested by Eero.
Carl Worth [Fri, 14 Jun 2013 18:29:33 +0000 (11:29 -0700)]
TODO: Add some additional items suggested by Eero.

Again, simply trying to ensure that good ideas that come in via email
don't get dropped on the floor.

 Report shader compilation time.

+Report elapsed time per frame.
+
+Add options to control which metrics should be collected.
+
 Add Eric's tiny hash table for collecting per-shader statistics

  people.freedesktop.org:~anholt/hash_table
@@ -45,6 +49,9 @@ Infrastructure (larger-scale things, more future-looking items)

 Use ncurses for a better top-like display.

+Report timestamps and CPU time durations for operations causing
+CPU/GPU syncs.
+
 Emit per-frame data in a format for external timeline viewer.

 Allow enabling/disabling of tracing at run-time
@@ -61,10 +68,16 @@ should automatically collect:

 Audit exisiting visualization tools before writing one from scratch

- Eero suggested that pytimechart might be well-suited:
+ Eero suggested two possibilities:

+ pytimechart
+ -----------
  http://pythonhosted.org/pytimechart/index.html

+ e-graph
+ -------
+ https://gitorious.org/e-graph
+
  Others?

 Explore using perf/LTTng probing instead of LD_PRELOAD wrapper

10 years agoTODO: Remove bug causing libfips-32.so to not build.
Carl Worth [Fri, 14 Jun 2013 18:11:42 +0000 (11:11 -0700)]
TODO: Remove bug causing libfips-32.so to not build.

The configure script now checks for this problem and won't attempt to
build a non-native-arch libfips if the toolchain pieces, (such as the
gcc-multilib package), are not in place.

10 years agoconfigure: Fully separate CFLAGS/LDFLAGS between fips and libfips
Carl Worth [Fri, 14 Jun 2013 06:29:07 +0000 (23:29 -0700)]
configure: Fully separate CFLAGS/LDFLAGS between fips and libfips

The top-level program and the underlying library have fundamentally
different requirements. For example, the top-level program needs to
link against libtalloc and libelf but the library does not.

Previously, the necessary flags for both were mixed together in
CONFIGURE_CFLAGS and CONFIGURE_LDFLAGS. This caused the library to
unnecessarily link against libtalloc and libelf, (which in turn caused
problems since the library is compiled as both 32-bit and 64-bit but
the system may not provide both 32- and 64-bit versions of these
libraries).

By splitting things up into separate FIPS_LDFLAGS vs. LIBFIPS_LDFLAGS,
etc. we can keep the dependencies down to what is really required and
eliminate several sprious failure cases.

10 years agoAdd more detailed warning if libfips binary could not be found.
Carl Worth [Fri, 14 Jun 2013 05:02:45 +0000 (22:02 -0700)]
Add more detailed warning if libfips binary could not be found.

Since we now may not compile a non-native bit-size libfips, (such as
not compiling libfips-32.so on a native 64-bit install), then fips can
fail when trying to wrap a 32-bit application.

So be kind and suggest that the user install gcc-multilib and
re-compile fips as one potential solution for this problem.

10 years agoconfigure: Test whether compiler can create both 32 and 64-bit binaries
Carl Worth [Fri, 14 Jun 2013 04:57:38 +0000 (21:57 -0700)]
configure: Test whether compiler can create both 32 and 64-bit binaries

If not, tell the user and recommend installing gcc-multilib. Then simply
don't attempt to compile the unspoorted library.

10 years agoconfigure: Move the code which detects compiler warning options
Carl Worth [Thu, 13 Jun 2013 22:39:30 +0000 (15:39 -0700)]
configure: Move the code which detects compiler warning options

For no good reason, this code was previously stuck right in the middle
of code reporting the final results of previous checks, (after the
case reporting that errors were found and before the case reporting
that no errors were found).

It's more clean to have the warning-option detection happen before any
of that reporting.

10 years agoconfigure: Switch from 4 spaces to tabs for some messages
Carl Worth [Thu, 13 Jun 2013 22:33:26 +0000 (15:33 -0700)]
configure: Switch from 4 spaces to tabs for some messages

Another cosmetic improvement to simply align the output more cleanly.

10 years agoconfigure: Add an early check for a functional C compiler
Carl Worth [Thu, 13 Jun 2013 22:00:49 +0000 (15:00 -0700)]
configure: Add an early check for a functional C compiler

Without this, later compiler-based checks for header files, etc. would
falsely claim that libraries were not installed, (when in fact, the
libraries were installed but the compiler-based checks were failing
because no compiler is available).

10 years agoconfigure: Tighten up the text on a couple of messages
Carl Worth [Thu, 13 Jun 2013 21:32:32 +0000 (14:32 -0700)]
configure: Tighten up the text on a couple of messages

Just a cosmetic thing to make the column of Yes/No messages align more
closely.

10 years agoconfigure: Move the error message for pkg-config earlier
Carl Worth [Thu, 13 Jun 2013 21:26:08 +0000 (14:26 -0700)]
configure: Move the error message for pkg-config earlier

Once pkg-config cannot be found, there's no point in running the rest
of the configure script since it will just spew a bunch of errors due
to missing pkg-config.

So, stop early and let the user know that pkg-config needs to be
installed.

10 years agoAdd a TODO file
Carl Worth [Thu, 13 Jun 2013 17:37:36 +0000 (10:37 -0700)]
Add a TODO file

This captures known bugs, planned (near-term) features, planned
(longer-term) infrastructure changes, and some ideas for other things
to investigate.

Many thanks to Eero Tamminen whose recent discussions and ideas
prompted the creation of this file, (and much of the content).

10 years agoeglwrap: Add EGLWRAP_DEFER and EGLWRAP_DEFER_WITH_RETURN macros
Carl Worth [Wed, 12 Jun 2013 23:35:59 +0000 (16:35 -0700)]
eglwrap: Add EGLWRAP_DEFER and EGLWRAP_DEFER_WITH_RETURN macros

There are parallel to GLWRAP_DEFER and GLWRAP_DEFER_WITH_RETURN, (differing
only in calling eglwrap_lookup rathern than glwrap_lookup).

Having these macros around will avoid some code duplication as we start
adding more functions to the eglwrap.c file.

10 years agoFix to actually load the real libGL.so when the application asks for it.
Carl Worth [Wed, 12 Jun 2013 23:22:06 +0000 (16:22 -0700)]
Fix to actually load the real libGL.so when the application asks for it.

Our wrapper library intercepts calls to dlopen "libGL.so" and returns
a handle to itself. That's correct, and as intended.

Before doing this, however, it's essential to actual dlopen "libGL.so"
for real even though we won't be returning a handle to it. This
ensures that any side effects from that dlopen are taken care of.

This fixes a bug where "fips apitrace replay foo.trace" would cause
Mesa to fail to load its driver as follows (with LIBGL_DEBUG=verbose):

libGL: OpenDriver: trying .../lib/dri/i965_dri.so
libGL error: dlopen .../lib/dri/i965_dri.so failed (.../lib/libdricore9.2.0.so.1: undefined symbol: _glapi_tls_Context)

10 years agodlwrap: Don't resolve libfips_handle on every call to dlopen.
Carl Worth [Wed, 12 Jun 2013 23:16:51 +0000 (16:16 -0700)]
dlwrap: Don't resolve libfips_handle on every call to dlopen.

Instead, call dladdr and the real dlopen on the first call to dlopen
then save the libfips_handle result for all future calls.

10 years agoSwitch from glGetQueryObjectiv to glGetQueryObjectuiv
Carl Worth [Wed, 12 Jun 2013 00:18:12 +0000 (17:18 -0700)]
Switch from glGetQueryObjectiv to glGetQueryObjectuiv

The latter is available in OpenGL ES 3 while the former is not.

We don't really care about the signedness either way, (we're fetching
a Boolean), so sticking consistently to the unsigned version provides
better portability with no downside.

10 years agoAdd a new GLWRAP_DEFER_WITH_RETURN macro.
Carl Worth [Mon, 10 Jun 2013 21:40:43 +0000 (14:40 -0700)]
Add a new GLWRAP_DEFER_WITH_RETURN macro.

This allows for the elimination of some code duplication from our
implementation of glXGetPrcAddressARB. The previous implementation
duplicated code from glwrap_lookup simply because the GLWRAP_DEFER
macro did not provide access to the return value of the wrapped
function.

With the new macro, (very much like GLWRAP_DEFER but accepting a
parameter for a variable to accept the return value), we can eliminate
this code duplication.

Of course, our symbol-extraction script is now a bit more complicated
since it has to find occurrences of DEFER_WITH_RETURN in addition to
occurrences of DEFER, and pull out the function name as the second
argument rather than the first.

10 years agoRemove typedef for fips_glXGetProcAddressARB_t
Carl Worth [Mon, 10 Jun 2013 21:34:26 +0000 (14:34 -0700)]
Remove typedef for fips_glXGetProcAddressARB_t

There were two problems with this typedef. First, we don't actually
need it, (we define it here and then use it exactly once on the next
line---it's simpler to have the direct syntax for a function returning
a pointer to a function accepting void and returning void.

More importantly, the typedef was relying on the type __GLXextFuncPtr
being defined. This happens to work with Mesa on my system but is
inherently fragile. So the code is more robust not relying on this.

10 years agoMakefile: Automatically generate libfips.sym symbol map
Carl Worth [Thu, 30 May 2013 22:10:15 +0000 (15:10 -0700)]
Makefile: Automatically generate libfips.sym symbol map

Previously, we had to manually maintain this table of symbols, (hence
it was too easy for the list to be stale). Instead, we now generate
the list automatically by examining the source code for symbols that
are wrapped.

10 years agolibfips.sym: Sort list in symbol map alphabetically.
Carl Worth [Thu, 30 May 2013 21:49:18 +0000 (14:49 -0700)]
libfips.sym: Sort list in symbol map alphabetically.

Where sort order is determined by "sort" utility.

This is to prepare for eventually generating this list automatically
from the source.

10 years agoAdd some *wrap_ prefixes to real_foo symbols.
Carl Worth [Thu, 30 May 2013 21:32:52 +0000 (14:32 -0700)]
Add some *wrap_ prefixes to real_foo symbols.

The intent here is to allow automated extraction of wrapper names by
grepping for symbols matching *wrap_real_<wrapper>.

10 years agoAdd two missing GL draw wrappers
Carl Worth [Thu, 30 May 2013 21:22:24 +0000 (14:22 -0700)]
Add two missing GL draw wrappers

The following two functions are now added:

glMultiDrawArraysIndirect
glMultiDrawElementsIndirect

These were previously commented out with a "FIXME" comment. I don't
recall now what original problem I ran into when trying to add these,
but they seem to work fine now.

10 years agometrics: Collect new timer-query results before report
Carl Worth [Thu, 30 May 2013 21:05:08 +0000 (14:05 -0700)]
metrics: Collect new timer-query results before report

The timers from the most-recently-completed frame may not yet be
complete, but still, for the most accurate reports, we now collect all
available timer values before printing the report.

10 years agodlwrap: Fix dlwrap_real_dlopen to only perform dlsym-lookup once
Carl Worth [Thu, 30 May 2013 19:55:26 +0000 (12:55 -0700)]
dlwrap: Fix dlwrap_real_dlopen to only perform dlsym-lookup once

Making the real_dlopen variable static means that we perform the dlysm
lookup only once and then re-use the result for later calls. This is
what was always intended for this code.

10 years agoAvoid inserting timer queries while constructing a display list
Carl Worth [Fri, 24 May 2013 18:11:15 +0000 (11:11 -0700)]
Avoid inserting timer queries while constructing a display list

We only want to time actual drawing operations. When between glNewList
and glEndList, calls that look like drawing operations are not really,
instead these are just calls that are being recorded to be later
executed with glCallList. (And it won't work to put our timer queries
inside the display list.)

So, track when we are within glNewList/glEndList and don't add timer
queries.  Instead, we will time these operations as a whole with a
timer query around the glCallList call itself.

10 years agoAvoid trying to start a timer query within glBegin/glEnd
Carl Worth [Fri, 24 May 2013 18:10:12 +0000 (11:10 -0700)]
Avoid trying to start a timer query within glBegin/glEnd

Instead, treat the entire sequence from glBegin..glEnd as a single drawing
operation and execute the timer query around the whole thing.

10 years agoAdd several missing symbols to the libfips symbol map.
Carl Worth [Thu, 23 May 2013 21:22:42 +0000 (14:22 -0700)]
Add several missing symbols to the libfips symbol map.

I'm not sure why these weren't added before, but without these in the
map, these calls were not being successfully wrapped, so these calls
were not being timed as they should have been.

In the future we should automatically generate the symbol list to
avoid any similar problems.

10 years agoRemove useless fork before executing wrapped program.
Carl Worth [Mon, 6 May 2013 18:57:24 +0000 (11:57 -0700)]
Remove useless fork before executing wrapped program.

The fork did nothing for us since the parent simply waited on the child
and then exited. It's simpler to simply exec the wrapped program, (which
simplifies running fips within a debugger, etc.).

10 years agoAdd support for OpenGL ES by conditionally compiling wrapper for eglSwapBuffers
Carl Worth [Mon, 6 May 2013 18:30:06 +0000 (11:30 -0700)]
Add support for OpenGL ES by conditionally compiling wrapper for eglSwapBuffers

The configure script now looks for EGL/egl.h, (via pkg-config or directly),
and if present, will compile a wrapper for eglSwapBuffers.

This allows fips to report metrics for OpenGL ES programs.

10 years agoMove metrics-tracking code from glwrap.c to new metrics.c
Carl Worth [Mon, 6 May 2013 18:18:33 +0000 (11:18 -0700)]
Move metrics-tracking code from glwrap.c to new metrics.c

We're moving toward having separate *wrap.c files for each flavor of GL,
(glwrap.c, glxwrap.c, and eglwrap.c). But this metrics-tracking code is
generic to all of those so belongs in a separate module.

10 years agoReduce code duplication with with new 'glwrap_lookup' function.
Carl Worth [Thu, 2 May 2013 21:33:12 +0000 (14:33 -0700)]
Reduce code duplication with with new 'glwrap_lookup' function.

We already had two copies of 'lookup', (and were anticipating additional
modules which needed it as well). The DEFER macro is now also exported
as GLWRAP_DEFER for use in additional modules.

11 years agoconfigure: Add checks for GL/gl.h
Carl Worth [Mon, 29 Apr 2013 21:54:52 +0000 (14:54 -0700)]
configure: Add checks for GL/gl.h

Previously, the compile would just forge ahead assuming GL/gl.h was present.

Now, at configure time, actually look for gl.h, (first, by looking for
a pkg-config "gl" package, otherwise, trying to just test-compile
something with a #include <GL/gl.h>).

If things aren't found at configure time, tell the user which packages
to install.

11 years agoFix glwrap.c to workaround 'const' changes in OpenGL headers.
Carl Worth [Mon, 29 Apr 2013 20:23:58 +0000 (13:23 -0700)]
Fix glwrap.c to workaround 'const' changes in OpenGL headers.

Not all OpenGL headers are created equal. Some include more "const"
keywords than others, and we don't know wheter the headers we are
compiling against include the extra "const". We force all to be equal
by using the preprocessor to remove all "const" keywords altogether.

11 years agoWrap all OpenGL drawing calls, measure GPU time of each, and account to shader.
Carl Worth [Thu, 25 Apr 2013 05:57:50 +0000 (22:57 -0700)]
Wrap all OpenGL drawing calls, measure GPU time of each, and account to shader.

Thanks to José Fonseca, there's a nice list of OpenGL functions identified
as "drawing operations" in the apitrace source. (It's mostly glDraw* but
there are a few oddball as well.) With that list we implement a wrapper
for each draw call.

And in each wrapper we fire of a glBeginQuery/glEndQuery measurement around
the call to measure how much GPU time is consumed by the call. At the end
of each frame, we capture all available query results and accumulate those
into per-shader-program counters based on the currently active program,
(which we track by wrapping glUseProgram and glUseProgramObjectARB).

Finally, every 60 frames, we print out a simple report showing the
accumulated time for each shader program.

The report could very easily become more sophisticated. Here are some
obvious ideas:

  1. Sort the report so that the most active shaders are reported first

  2. Come up with some real units for the report values rather than mega-ticks

  3. Report relative execution time as percentages

  4. Clear the screen for each report, (with ncurses)

  5. Dump the source for the shaders themselves to a file for easy inspection

Without any of the above, things are fairly raw for now, but are
perhaps still useful.

11 years agoGeneralize glXGetProcAddressARB wrapper to work for all wrapper functions
Carl Worth [Thu, 25 Apr 2013 05:55:01 +0000 (22:55 -0700)]
Generalize glXGetProcAddressARB wrapper to work for all wrapper functions

The originally implementation here had a whitelist of function names for
which we would return a wrapped symbol, (a very short whitelist consisting
only of "glXSwapBuffers"). A hard-coded list here would be a maintenance
nightmare.

Instead, we now simply perform a dlsym lookup on the wrapper library itself
and if there's a function that exists in the library matching the name
being requested, we return that.

This way we can add functions to our wrapper library without needing to
change the implementation of glXGetProcAddressARB at all.

11 years agoFix 3 separate off-by-one error in as many lines of code.
Carl Worth [Thu, 25 Apr 2013 05:52:50 +0000 (22:52 -0700)]
Fix 3 separate off-by-one error in as many lines of code.

This one is quite embarrassing, and is evidence that I should have
gone to bead earlier last night.

11 years agoMove include of dlfcn.h to dlwrap.h
Carl Worth [Wed, 24 Apr 2013 22:36:23 +0000 (15:36 -0700)]
Move include of dlfcn.h to dlwrap.h

It only makes sense to make this header file pull in the underlying
dlfcn.h.

While in the area, also drop an unneeded include of GL/glext.h, (which
gets pulled in by GL/gl.h).

11 years agoAdd a simple fips.h file.
Carl Worth [Wed, 24 Apr 2013 22:28:43 +0000 (15:28 -0700)]
Add a simple fips.h file.

This pulls in a few widely-used header files, (config.h, stdio.h,
stdlib.h, and string.h), and also gives us a place to define common
macros such as unused and STRNCMP_LITERAL.

11 years agoAppend to, rather than replace, the LD_PRELOAD value.
Carl Worth [Wed, 24 Apr 2013 08:08:54 +0000 (01:08 -0700)]
Append to, rather than replace, the LD_PRELOAD value.

This is more polite for running things such as Steam games where there
is already an LD_PRELOAD value in place. This way, both the Steam overlay
and fips can get along happily.

11 years agofixup __dlsym
Carl Worth [Wed, 24 Apr 2013 22:26:35 +0000 (15:26 -0700)]
fixup __dlsym

11 years agoAdd wrappers for dlopen, dlsym, and glXGetProcAddressARB
Carl Worth [Wed, 24 Apr 2013 07:58:26 +0000 (00:58 -0700)]
Add wrappers for dlopen, dlsym, and glXGetProcAddressARB

This allows for many applications to start working with fips that would not
work before. Specifically, applications that dlopen libGL.so.1 instead of
directly linking with it would previously bypass fips' attempts to wrap
GL calls.

With these new wrappers carefully in place, many applications now work.

I've verified the following applications at least:

apitrace replay
NightSkyHD, a Humble Bundle game, both 32 and 64-bit versions
World of Goo, via Steam

I was also happy to notice that the Steam overlay does not cause fips
any difficulties.

11 years agoFix fips to work without requiring an absolute path for program to run.
Carl Worth [Wed, 24 Apr 2013 00:47:20 +0000 (17:47 -0700)]
Fix fips to work without requiring an absolute path for program to run.

With the latest commit that examines the ELF header of the program to
run fips was suddenly requiring that the absolute path of the program
be provided. This was obvisouly not desired.

It's simple enough to search through the PATH environment variable to
find the absolute path of the program to be run and examine that.

11 years agoCompile both 32-bit and 64-bit versions of the wrapper library.
Carl Worth [Wed, 24 Apr 2013 00:25:13 +0000 (17:25 -0700)]
Compile both 32-bit and 64-bit versions of the wrapper library.

This is intended to make it transparent to run fips with either a
32-bit or a 64-bit program. And it does do that once you successfully
build both versions of the library.

Actually being able to build both versions of the library is a little
tricky though. Here are some of the tricks:

1. You will need to have installed both a 32-bit and a 64-bit .so file
   for each dependent library, (currently libelf and libtalloc).

   The current configure script doesn't check for both versions, so
   you don't get a lot of guidance here. And that's because...

2. On Debian, at least, one cannot currently install both
   libtalloc-dev:amd64 and libtalloc-dev:i386 at the same time.

   Contrast with libelf-dev:i386 and libelf-dev:amd64 which work just
   fine when installed simultaneously.

One can work around this by just install libtalloc-dev:amd64 and then
manually creating the link you need for the i386 package. Namely:

sudo ln -s libelf.so.1 /usr/lib/i386-linux-gnu/libelf.so

11 years agoStart wrapping OpenGL, and print periodic FPS value to stdout.
Carl Worth [Tue, 23 Apr 2013 21:17:33 +0000 (14:17 -0700)]
Start wrapping OpenGL, and print periodic FPS value to stdout.

In addition to the fips binary, we now also compile a libfips.so library
and LD_PRELOAD that before executing the program specified on the command-
line.

The libfips.so library wraps OpenGL calls of interest for purpose of
instrumentation. So far, the only call wrapped is glXSwapBuffers and
the only instrumentation is to compute and print out a frames-per-second
value every 60 frames.

11 years agoAdd the ability to execute a program.
Carl Worth [Mon, 22 Apr 2013 23:03:07 +0000 (16:03 -0700)]
Add the ability to execute a program.

Simply fork and exec the command-line arguments given.

(Nothing is actually changed yet about the environment in which the
program is executed.)

11 years agoMove dist, release, etc. targets to new Makefile.release
Carl Worth [Tue, 23 Apr 2013 17:22:29 +0000 (10:22 -0700)]
Move dist, release, etc. targets to new Makefile.release

The Makefile.local was getting far too cluttered with all of this
stuff mixed in.

11 years agoInitial commit of fips repository
Carl Worth [Mon, 22 Apr 2013 21:24:30 +0000 (14:24 -0700)]
Initial commit of fips repository

Just a build system and a stub of a main program for now, (which
doesn't do anything yet).