I'm working with an art student on a renderer that visualizes
textual communication. I have it working very nicely except that
I'd like to speed it up a little bit on large chunks of text (ie.,
>500 letter objects). So I ran it through OpenGL Profiler and was
kind of surprised. After doing simple things like disabling calls
to glFlush(), the top three functions that take up the time in
OpenGL are CGLFlushDrawable, glBegin, and glVertex. glBegin and
glVertex don't surprise me (although I wonder if there is some way
of optimizing glBegin a bit) especially seeing that glVertex takes
only 1% of the time in OGL with glBegin only slightly larger at
2.1%... but CGLFlushDrawable is taking a whopping 95% of the time,
which just seems odd, but since I haven't done much optimization I
don't know if I it or not.
So my question is, am I doing something wrong, or is there a way to
optimize CGLFlushDrawable down?
Usually when you see this it means you've bumped up against hardware
limits, or if you happen to have your swap interval set to >0, you're
trying to exceed the framerate of the display.
There is code in the graphics drivers stack to make sure that any
time you issue a swap, you get blocked until any *previous* swap (not
the one you are just issuing) has at least made it out to the screen.
This was done because otherwise many applications can find
themselves multiple frames ahead of the graphics hardware. This
makes using mission critical applications like Quake very difficult,
among other things. ;)
-Ken
I'm getting a similar profile (almost all time spent in
CGLFlushDrawable), though the GL profiler tells me that only ~15% of
the app's time is being spent in GL. Shouldn't this % be a lot higher
if the hardware is the bottleneck?
Another discrepancy is in the theoretical vs. actual performance
increase by reducing time spent in GL -- using an estimate similar to
the one in Apple's tech note on OpenGL performance optimization
(http://devworld.apple.com/technotes/tn2004/tn2093.html) my app should
only be able to improve by about 2-3 frames per second if I reduce
time spent in GL to 0, but by disabling various effects (which reduces
the % time in GL by about half but retains about the same % CPU usage)
I get more than double the frame rate. This makes me think that I
can't trust this statistic, or that it doesn't mean what I think it
does. Is it just the time spent by the driver but not by the
hardware?
Yeah, it is essentially monitoring how much CPU time your app is
spending inside of GL calls (which includes driver work). If you want
to see how much time your app (or the system in general) is spending
waiting on the hardware, the driver monitor stuff in profiler is the
way to go.
-Ken
Kenneth Dyke, email@hidden (personal), email@hidden (work)
Sr. Mad Scientist, MacOS X Quartz Effects Group, Apple Computer, Inc.
C++: The power, elegance and simplicity of a hand grenade.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden