Strange encounters of the FPS kind

Howdy list,

I have observed, and gather you will hear similarly, coincidentally,
from someone else soon, that my computer runs apps that use SDL and
the SDL_GL_Swap_Buffers functions at exactly 60fps, or lower if
computations are tough. That is to say, frames per second never go
higher than 60fps, even for a program that tries nothing more than
rendering three rectangles.

Has anybody got any suggestions for investigating what would cause
this, and how to deal with it?

The two example applications I can name are:

  • The ingenious first person shooter game, Cube 3D, with sizeable maps
    and (comparatively) large numbers of triangles
  • my own very tiny humble application which draws three rectangles as
    fast as possible

Both of these run at 60 fps. I’m very much doubting that my very very
poor little application is taking as much time to do everything as
Cube 3D.

Thanks for any help!

Christian L?ger

I have observed, and gather you will hear similarly, coincidentally,
from someone else soon, that my computer runs apps that use SDL and
the SDL_GL_Swap_Buffers functions at exactly 60fps, or lower if
computations are tough. That is to say, frames per second never go
higher than 60fps, even for a program that tries nothing more than
rendering three rectangles.

That’s vertical synchronization. You probably have an LCD monitor (or
a CRT that must be really annoying to look at for long periods of
time), so when you do the first SDL_GL_Swap_Buffers, it puts it on the
screen (in the background), but you can’t do another one for another
60th of a second. That’s the right moment to do all of your
non-graphics time-consuming stuff, like physics calculation, or
whatever it is you do, because if you don’t bother, draw right away
and try to SDL_GL_Swap_Buffers again, it will block until the previous
one is finished.

So, have a drink and take it easy while we swap your buffers! ;-)On Wed, Jun 24, 2009 at 12:16 AM, Christian Leger<chrism.leger at gmail.com> wrote:


http://pphaneuf.livejournal.com/

I have observed, and gather you will hear similarly, coincidentally,
from someone else soon, that my computer runs apps that use SDL and
the SDL_GL_Swap_Buffers functions at exactly 60fps, or lower if
computations are tough. That is to say, frames per second never go
higher than 60fps, even for a program that tries nothing more than
rendering three rectangles.

That’s vertical synchronization. You probably have an LCD monitor (or
a CRT that must be really annoying to look at for long periods of
time), so when you do the first SDL_GL_Swap_Buffers, it puts it on the
screen (in the background), but you can’t do another one for another
60th of a second. That’s the right moment to do all of your
non-graphics time-consuming stuff, like physics calculation, or
whatever it is you do, because if you don’t bother, draw right away
and try to SDL_GL_Swap_Buffers again, it will block until the previous
one is finished.

So, have a drink and take it easy while we swap your buffers! :wink:

This is correct, as far as it goes. Most OSes provide a way turn off
synchronization with vertical retrace. It is there under display settings.
At worst you would need to download the vendor provided settings program for
your video card. Once, vblank synch is turned off, your 3 polygon
application will run much faster.

In truth, if your application draws images faster than your video display
can show them, then it is just wasting time. Even if your graphics system
can draw your 3 tris at 20,000 FPS, you can still on get about 60 images to
the display each second.

Bob PendletonOn Tue, Jun 23, 2009 at 11:38 PM, Pierre Phaneuf wrote:

On Wed, Jun 24, 2009 at 12:16 AM, Christian Leger<chrism.leger at gmail.com> wrote:


http://pphaneuf.livejournal.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------

I have observed, and gather you will hear similarly, coincidentally,
from someone else soon, that my computer runs apps that use SDL and
the SDL_GL_Swap_Buffers functions at exactly 60fps, or lower if
computations are tough. That is to say, frames per second never go
higher than 60fps, even for a program that tries nothing more than
rendering three rectangles.

That’s vertical synchronization. You probably have an LCD monitor (or
a CRT that must be really annoying to look at for long periods of
time), so when you do the first SDL_GL_Swap_Buffers, it puts it on the
screen (in the background), but you can’t do another one for another
60th of a second. That’s the right moment to do all of your
non-graphics time-consuming stuff, like physics calculation, or
whatever it is you do, because if you don’t bother, draw right away
and try to SDL_GL_Swap_Buffers again, it will block until the previous
one is finished.

So, have a drink and take it easy while we swap your buffers! :wink:

And, this is exactly why some systems are triple buffered. That gives
you one buffer that is being displayed, one that is waiting to be
displayed, and one more that you can render into.

Bob PendletonOn Tue, Jun 23, 2009 at 11:38 PM, Pierre Phaneuf wrote:

On Wed, Jun 24, 2009 at 12:16 AM, Christian Leger<chrism.leger at gmail.com> wrote:


http://pphaneuf.livejournal.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------

Hey,

Thanks for the answers! I did think it had to do with an OS setting,
because in linux it goes at 800fps!On Wed, Jun 24, 2009 at 12:16 AM, Christian Leger<@Christian_Leger> wrote:

I have observed, and gather you will hear similarly, coincidentally,
from someone else soon, that my computer runs apps that use SDL and
the SDL_GL_Swap_Buffers functions at exactly 60fps, or lower if
computations are tough. That is to say, frames per second never go
higher than 60fps, even for a program that tries nothing more than
rendering three rectangles.

That’s vertical synchronization. You probably have an LCD monitor (or
a CRT that must be really annoying to look at for long periods of
time), so when you do the first SDL_GL_Swap_Buffers, it puts it on the
screen (in the background), but you can’t do another one for another
60th of a second. That’s the right moment to do all of your
non-graphics time-consuming stuff, like physics calculation, or
whatever it is you do, because if you don’t bother, draw right away
and try to SDL_GL_Swap_Buffers again, it will block until the previous
one is finished.

So, have a drink and take it easy while we swap your buffers! :wink:


http://pphaneuf.livejournal.com/