]> git.cworth.org Git - fips/commit
Wrap all OpenGL drawing calls, measure GPU time of each, and account to shader.
authorCarl Worth <cworth@cworth.org>
Thu, 25 Apr 2013 05:57:50 +0000 (22:57 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 25 Apr 2013 05:57:50 +0000 (22:57 -0700)
commitb8b9a79e315bf3a030c3b0840ad1490746b5a8e0
tree0dc368da6c82de46e0807b27833e55bafa31a3a3
parent7f48ed429b393b28cb6362af5dcddd9bb27c3901
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.
Makefile.local
glwrap.c [new file with mode: 0644]
glwrap.h [new file with mode: 0644]
glxwrap.c
libfips.sym