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.
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.
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.
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.
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.
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.
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.
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:
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.