PDA

View Full Version : timing when vertical sync is ON



SergeVrt
08-04-2003, 10:33 PM
I am running the application with GL_SYNC_TO_VBLANK=1 ( Vertical sync is ON), thus framerate is 60
Hz (given video rate of 60 Hz). What I need to do is to determine the
"actual" rendering time which is needed to render the image including FSAA.
i.e. the time from the first openGL call until the image is completely drawn in
the backbuffer including AA (Anti-Aliasing).

How do I get this time. Just measuring time between my first and my last
openGL call seems to deliver time without AA.

any suggestions?

DopeFish
08-04-2003, 11:51 PM
Start your timing before any rendering, and at the end, call glFinish() and then end your timing after that returns.

golem
07-27-2005, 05:27 AM
On NVIDIA hardware, if you do a timing after glFinish, you will not get the actual rendering time but a multiple of the video frequency (assuming vsynch is on).
So for instance, if you do:

start = getClock();
glClear();
wglSwapBuffers();
glFinish();
frame_duration = getClock() - start;

you will get 16.66 ms (if your frequency is set to 60Hz)

what you should do is :

start = getClock();
glClear();
glReadPixels(1 pixel);
frame_duration = getClock() - start;
wglSwapBuffers();
glFinish();

you issue a blocking glReadPixels to force the GPU to rasterize all pending polygons. You do a timing right after that but *before* glFinish

golem
07-27-2005, 06:25 AM
i just realized the following will also work :

start = getClock();
glClear();
glFinish();
frame_duration = getClock() - start;
wglSwapBuffers();
glFinish();

I don't understand why the second call to glFinish waits for the next vertical retrace and the first call does not.

Any ideas ?

Relic
07-27-2005, 06:31 AM
Not the glFinish waits for vertical retrace, the wglSwapBuffers does.

golem
07-27-2005, 06:42 AM
i think you are wrong
i have tried :

start = getClock();
glClear();
wglSwapBuffers();
frame_duration = getClock() - start;
glFinish();

and i don't get 60Hz but a much higher value.
this proves wglSwapBuffers is not blocking

Relic
07-27-2005, 07:23 AM
>>I don't understand why the second call to glFinish waits for the next vertical retrace and the first call does not.<<

I meant glFinish has nothing to do with vertical retrace. It just waits until OpenGL has finished rasterization.
Your measurements show that the wglSwapBuffers call doesn't block by itself but will not happen until the next vertical retrace because the glFinish didn't return until that swap "rasterization" had finished.

golem
07-27-2005, 08:43 AM
i think you are right !!

now i understand
thanks