I was reading through some old mac-games-dev mailing list messages earlier
today, and ran across some where the developers were saying that SDL
performance on OS X in windowed mode was pretty terrible. (John Stiles, the
author of Candy Crisis, had ported his game – which used to run well on a
100mhz PowerMac, to SDL – and it would then drop frames on a far faster
computer… I think over 1 GHz if I remember correctly.)
I’ve just started experimenting with SDL, and it seems that little has
changed. But specifically, I can take the “Aliens” demo (added the source
code to the latest SDL 1.2.14 Cocoa project template), and if I remove the
frame rate limit, it’ll drop significantly in speed the larger I make the
window size. (Fullscreen this does not happen.)
Its behavior is consistent with a program that redraws the entire window
every frame, rather than just updating delta rects. But this is not
necessary, as dirty rects can/should be used.
Examples:
Fullscreen: 255 fps
Windowed 640x480: 60fps
Windowed 1024x768: 42 fps
Windowed 1280x800: 30fps
It appears that while fullscreen, SDL properly does dirty rects, and does
not redraw the entire video memory buffer every frame. But in Windowed mode,
it seems that it likely does.
First, is this fixed in SDL 1.3? Second, if not, are there any plans to
address this?
I just looked at the source code in the aliens tar.gz file at
http://www.libsdl.org/projects/aliens/. The code, as posted on the web
site, uses dirty rectangles correctly and nothing inside of SDL 1.2
would allow the program to run without dirty rectangles working
correctly. That means this is not a problem with dirty rectangles, it
has to be somewhere else.
The original code calls for a software buffer. That means that SDL
should create the surface in system memory, use dirty rectangles to
update the buffer in memory, and then blit that whole buffer to the
display memory. That is what a software buffer does. So yes, it looks
like it is always doing a blit because it is. So, the “bug” is coded
into the original code. At the time the program was written, ten years
ago in December of 1999 the way it was written was not a bad way to
go. Times have changed?
The difference in speed between full screen and windowed updates seems
to be saying that OS X is only allowing blits to windows during
vertical refresh (the 60 hz frequency kind of gives it away) but is
allowing blits in full screen mode at any old time. I don’t know
because I haven’t spent the time to dig into the OS X rendering code.
SDL 1.3 works in a very different way. It will only use a shadow
buffer if it needs one to maintain compatibility with SDL 1.2 APIs
that are now only supported through emulation. Basically, the way
aliens was written back in December of 1999 was the best way to do it.
But that was 10 years ago. It is no longer a reasonable way to write a
game and SDL 1.3 is being implemented to use techniques that are
likely to be valid for at least the next 10 years.
Seriously, 10 years? That is 5 cranks of Moore’s Law. That represents
a 2**5 or 32 times increase in computer performance.
Bob PendletonOn Thu, Dec 10, 2009 at 6:03 PM, VernJensen wrote:
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
±----------------------------------------------------------