FPS, how to calculate this?

My OpenGL book says the following:

โ€œWhat often happens in such a system is that the frame is too complicated to draw in 1/60 second, so each frame is displayed more than once. If, for example, it takes 1/45 second to draw a frame, you get 30 frames in second, and the graphics are idle 1/30 1/45 = 1/90 seconds per frame, or one third of the time. "

The sentence, which says: "it takes 1/45 second to draw a frame, you get 30 frames per second", why do I get only 30 frames per second? Perhaps more correct 45 fps?

+7
opengl frame-rate
source share
3 answers

A video card will usually only buffer one frame forward.

If it takes 1/45 second to draw a frame, then the previous frame will be displayed again at 1/60 of the second mark. The next frame is executed at 1/45, but there is no free buffer on the card to start playing the next one, so you have to sit idle until 1/30, where it can send this frame and start working on the next one.

This is with VSync enabled - if you disable it, instead of receiving 30 frames per second and an unoccupied card 1/3 times, the card will start redrawing immediately, and instead you will get screen breaks.

+12
source share

It is right. You will get 45 frames per second, but the system slows it down to 30 frames per second in order to achieve a smooth frame rate on monitors with a frequency of 60 Hz (60 repeats per second).

Since you need to draw something every 1/60 second on a 60 Hz monitor and cannot draw โ€œhalf frameโ€, you must draw the previous Frame. So if you are 60 times per second, you once draw a real frame, and every 2 frames you draw the first, then you get 30 frames per second, despite the fact that you can manage 45 frames per second.

+5
source share

So, as others have said, this is because your graphics are waiting for v-synchronization before generating the next frame.

That said ...

Beware, not all monitors are updated at 60 Hz. 60 frames per second versus 30 frames per second is 70 frames per second versus 35 frames per second on a display with a frequency of 70 Hz.

If you do not want your card to wait for v-synchronization before the start of the next frame, but avoid gap anyway, use triple buffering. Then the GPU, and then the ping pong, displays 2 buffers while the 3rd is displayed. The v-sync event is what triggers the swap to the "ready" back buffer. This is still not very cool, because in the end you get several frames that remain on the screen more often than others: with your rendering, 1/45 the frame will remain for 1/30 seconds, and the next one at 1/60, giving some jerk.

Finally, with the advent of off-screen rendering (rendering on non-displayable buffers), it is theoretically possible that the driver does not wait for v-synchronization before the start of the next frame if the early work of this next frame happens so as not to touch the display surface. I don't think I've ever seen a driver be so smart though.

0
source share

All Articles