View Full Version : How to measure rendering time ?

06-01-2004, 09:13 AM
It seems that glFinish is a non blocking call on some graphics cards.
If i want to measure rendering time of my scene, do i have to call glReadPixels of 1 pixel just before swap buffers (to make sure every triangle is finished to be rasterised) ?

Are there easier solutions ?

P.S. vertical sync has to be on for my application

06-01-2004, 12:34 PM
Are you sure that glFinish() is non-blocking? Isn't it possible that the card you're using is fast enough that there's nothing left to finish?

Reading back a pixel is a tried-and-true way of synchronizing, for sure. However, usually, timing a single frame won't give you very good data; you'll need to measure a number of frames (at steady state) and divide time by frame count to get a "good" measurement.

06-01-2004, 01:10 PM
glFinish should be blocking, I've used it to WAR problems with cards that don't block where they should. What card do you see it non blocking on?

06-02-2004, 09:39 AM
Yes, glFinish is a blocking call. I confused myself.

However when does glFinish actually return to the application ? Is it right after the rasterisation of the last triangle or is it at the next vertical retrace (in this case, a precise timing of the rendering time is impossible and the only solution i can see is to use glReadPixels instead).

is it driver dependent ?

06-02-2004, 12:12 PM
I believe you can convince the specification to mean that the last triangle has been rasterized to the frame buffer, but glFinish() does not know anything about vertical retrace. Indeed, the framebuffer might not even have a scan-out!

If you need advanced genlock, you need to buy special hardware that comes with special drivers that can support that. If you need just flicker-free output, then making sure vsync is on, and keeping up with frame rates, should be sufficient.