Profiling OpenGL

Diagnosing OpenGL performance problems can be difficult so it helps to know some tools that can measure performance.

OpenGL Profiler

MacOS X has a nice profiling program called OpenGL Profiler that can attach to programs and measure their OpenGL performance. OpenGL profiler can also extract a trace of GL function calls so you can look for functions that can cause performance problems.

  • OpenGL Profiler is typically located in the Macintosh HD volume under the Developer/Applications/Graphics Tools directory.

OpenGL Profiler provides 2 really nice features:

  • Attach to program
  • Collect trace

OpenGLProfiler.png

Attach to program

The attachment feature lets you connect to a running OpenGL program and start measuring its OpenGL performance. The frames per second is prominently displayed in the OpenGL Profiler window.

When measuring VisIt performance, you can start OpenGL Profiler and attach to the viewer process in the list of processes. Measurement will begin immediately and you can start moving the plot with the mouse to make the vis window redraw the frames. You can also put the vis window into spin mode and give it a whirl to make VisIt try and render frames as fast as it can. Once you have a measurement, you can detach from VisIt.

You can also measure the performance of the X11 version of VisIt displaying back to the Mac from a remote computer. Since there is no local viewer process to attach, you can instead attach to the X11.bin application and VisIt will measure the performance of the X-server as it services the remote viewer's GL function calls. As with the local viewer, the OpenGL Profiler will give you the FPS of the remote VisIt.

Collecting a trace

Sometimes it is helpful to know which GL function calls an application has issued if the performance is not adequate. You can examine the trace to look for function calls that are slowing down execution. For example, excessive state changes or querying GL state in the middle of rendering significantly affect the frame rate of the application. You can look for these sorts of function calls and change the code to move them or eliminate them entirely, producing faster GL code.

  1. Open the Trace window using the Views->Trace menu to see the window that will collect the GL functions.
  2. Set up VisIt with the plots that you want to draw but do not click Draw yet.
  3. Click the Collect Trace button in OpenGL Profiler.
  4. Attach OpenGL Profiler to the viewer or X11.bin, depending on where VisIt is running.
  5. Click the Draw button in VisIt. You will see a bunch of GL functions in the Trace window.
  6. Detach OpenGL Profiler from VisIt.
  7. Click the Save As Text button in the Trace window.

The default output from the trace will contain timing information. You can turn that off by unchecking the Timing check box. Or, you can postprocess the function calls with a script to remove the timings.

OpenGLProfilerTrace.png

Example

The trace function was used to compare the performance of VisIt 2.3.0 and VisIt 2.4.1 since 2.4.1 was reported to be much slower than 2.3.0. The same plot was created in each version of VisIt and a trace was made for each. The resulting OpenGL calls were compared using xdiff and the differences were identified. Eventually, the slowness in VisIt 2.4.1 was traced to the addition of a glGetIntegerv function call that was made repeatedly from VTK's vtkOpenGLProperty class. Fortunately, the glGetIntegerv function could be removed, restoring performance to about 59 FPS up from the 13 FPS that was obtained from the unmodified VTK 5.8.

gDEBugger

gDEBugger is an OpenGL debugging and profiling tool for Linux, Mac, and Windows. explain how to use it...