Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open-source OpenGL profiler for Linux [closed]

The title sums my question up pretty well: are there any open source OpenGL profilers for Linux?

The only thing I could find was gDEBugger, but it only comes with a 7 day trial and is very much closed source. I would use this for free (as in freedom) software development so paying is not an option, though I might consider accept answers for a free (as in beer) but closed application. Bonus points if it works with open source drivers (my main computer has an integrated Intel graphics card).

like image 418
Staffan Avatar asked Jul 13 '10 09:07

Staffan


3 Answers

Thanks to @cypheon's answer, I checked out BuGLe. It is fantastic, but I had to spend a bit of time getting useful profiling output. I wanted to add this as a comment on that answer, but I really need to paste full code examples so I started a new answer.

As he suggested, the stats_calltimes filter is good for profiling -- not ideal (since it doesn't show call stack information), but with a bit of work, it can show you the total flat time for each GL function per frame.

You need to edit both the ~/.bugle/filters and ~/.bugle/statistics files. Firstly, add this chain to the end of filters:

chain showcalltimes
{
    filterset stats_calls
    filterset stats_calltimes
    filterset showstats
    {
        show "average time per call"
    }
}

Now run your program with the command:

BUGLE_CHAIN=showcalltimes LD_PRELOAD=libbugle.so <your-program>

This will print the average time spent in each GL function per frame. That isn't terribly useful by itself, because for a call like glVertex, called thousands of times per frame, it will probably show up as 0.00ms even though the cumulative time is quite significant. So add a new entry to statistics:

"total time per call" = d("calls:*") / d("calls:*") * d("calltimes:*") / d("frames") * 1000
{
    precision 3
    label "* (ms)"
}

I used the same trick as the "calls per frame" statistic: multiply and divide by d("calls:*") to cause a divide-by-zero error for any function that was never called, to avoid showing 0.00 for all of the irrelevant functions.

Now, go back to the showcalltimes chain we added to filters, and change "average time per call" to "total time per call":

chain showcalltimes
{
    filterset stats_calls
    filterset stats_calltimes
    filterset showstats
    {
        show "total time per call"
        #key_accumulate "A"
        #key_noaccumulate "I"
    }
}

And now we will see the useful stat of the total time spent in each function, per frame. If you want to average these stats out over many frames, uncomment the key_accumulate lines above, and then you can hit "A" (or remap it to a key of your choice) to start accumulating. Over time, you will see the statistics stop bouncing around so much as they average out over many frames.

You can also log these statistics to an output file with this chain:

chain logcalltimes
{
    filterset stats_calls
    filterset stats_calltimes
    filterset log
    {
        filename "bugle.log"
    }
    filterset logstats
    {
        show "total time per call"
    }
}

This is pretty hard to read, since it simply puts the individual stats for each frame one after the other, and I haven't found a way to average them over time. So my preferred method for reading statistics is the showcalltimes chain with the accumulator turned on.

like image 133
mgiuca Avatar answered Oct 13 '22 22:10

mgiuca


Have a look at BuGLe. Its main target is not profiling, but it has a filter, which shows the time spent in each OpenGL call.

like image 33
cypheon Avatar answered Oct 13 '22 23:10

cypheon


I would really recommend this small profiler:http://silverspaceship.com/src/iprof/, it is not bound to profiling opengl, but does so very well! Also it can use opengl to display the profiling stats, which means it is very portable.

like image 39
Greget Avatar answered Oct 14 '22 00:10

Greget