SDL_GL_SwapBuffers() with and without SDL_GL_DOUBLEBUFFER

Hello,
I’m new here, but I have a doubt.

When I comment my Render function, I get ~ (511131, 513663, 509512) loops/second.

This is my Render function:

Code:
glClear( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapBuffers();

When I call Render function, with DoubleBuffer on, I get (2548, 2436, 2432) loops/second.
When I call Render function, without DoubleBuffer on, I get (18731, 18774, 18749) loops/second.

Why, even without V-Synchronization, I can’t get ~ 9000 when Double Buffer are enabled?

I’m using SDL-1.2.14 under GeForce 8800 GTS, OpenGl 3.1, Windows XP, MinGw + Code::Blocks;

Anyone know how I can get FPS higher than 2500 with Double-Buffering?

Hello,
I’m new here, but I have a doubt.

When I comment my Render function, I get ~ (511131, 513663, 509512)
loops/second.

This is my Render function:

Code:

glClear( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapBuffers();

When I call Render function, with DoubleBuffer on, I get (2548, 2436,
2432) loops/second.
When I call Render function, without DoubleBuffer on, I get (18731, 18774,
18749) loops/second.

Why, even without V-Synchronization, I can’t get ~ 9000 when Double Buffer
are enabled?

Well, the answer to that is that it takes that much time for your 8800 GTS
plus the current version of the NVidia driver to fill your window with the
specified color and swap the buffers. That all there is to it.

You don’t tell us how big the window is, so we can’t compute the amount of
memory is being filled and moved. You don’t tell us if you are running full
screen or not so we don’t know how much work the card and driver have to do
to accomplish what you are asking it to do.

Let me just go over a couple of things. The SDL_GL_SwapBuffers() call just
calls the system specific function to swap the buffers. This would be a WGL
function on Windows. What does that function have to do? In the simplest
case, for a full screen window, it might be able to just change a pointer so
that the display hardware just starts drawing from a different location in
memory. OTOH, if it is a window, and maybe even if it is full screen, then a
swap may require that the entire contents of the buffer be copied to the
location of the current display buffer. That can take a while. Or, well,
there are lots of other ways to implement swapping, most have time
proportional to the number of pixels being displayed. So, it takes some
time.

Why does the fill without double buffering go so fast? Do you actually leave
the SwapBuffers call in when you don’t have double buffers? Well, it doesn’t
really mater, if you don’t have two or more buffers then the swap doesn’t do
much. In fact, it doesn’t do anything at all. I don’t know for sure, but
there is a good change that SDL doesn’t even call the actaul swap function
in that case. But, I am sure that doing nothing takes less time than doing
something. How much less depends on how soon it is noticed that you don’t
actually want to do anything. It will be faster if SDL notices, a little
slower if Windows notices, even slower if the driver notices.

And, you know, there is a chance that the driver or the hardware will notice
that you are just sending clear commands and ya’know if someone wants me to
paint a fence 10 different colors in a row I just might optimize that by
just painting it the last color. A good driver might do that, might not.

Have you computed how many pixels you might be copying and compared that to
the copy rate of your card? Clearing the buffer just requires a simple write
to video memory. The simple right can be handled by the lowest level of the
GPU, the level closest to the memory. So, it can be done in parallel. A copy
requires a read and a write. So, the information has to flow across the bus.
A lot can be done in parallel, but the on chip and on card buses become a
blocking resource when you do a copy.

I gotta ask, is there a reason why you expect it to be faster? Why do you
want it to be at least 9000 draws per second? I ask because while I am
amazed by the speed of some new video display I am not aware of a single one
that can display 900 frames per second.

Bob PendletonOn Sun, Dec 6, 2009 at 5:07 AM, renato.cron <renato.cron at gmail.com> wrote:

I’m using SDL-1.2.14 under GeForce 8800 GTS, OpenGl 3.1, Windows XP, MinGw

  • Code::Blocks;

Anyone know how I can get FPS higher than 2500 with Double-Buffering?


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


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