From: Carl Worth Date: Thu, 25 Apr 2013 05:57:50 +0000 (-0700) Subject: Wrap all OpenGL drawing calls, measure GPU time of each, and account to shader. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=b8b9a79e315bf3a030c3b0840ad1490746b5a8e0;hp=b8b9a79e315bf3a030c3b0840ad1490746b5a8e0;p=fips 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. ---