I spent some time investigating the performance of Simutrans on Mac, since I'm in a similar situation. I have a 15" Macbook Retina, OS X 10.8.3, running at 1920x1200. I have compiled Simutrans from source using SDL 1.2.15. When I maximize Simutrans, its framerate drops from 25fps to 5fps. Here are the observations that I've made:
- SDL runs in software mode when running windowed.
- SDL_Flip() takes about 150ms to execute. In software mode, that's equivalent to SDL_UpdateRect(screen, 0, 0, 0, 0), which is not fast. That accounts for almost the entire frame drawing time.
- Incidentally, I spent some time getting multithreaded mode to work on Mac. The main barrier is lack of pthread barrier support. But once I found that the multithreaded portions of simutrans were not the bottleneck, I abandoned this work.
- I get decent performance with hardware acceleration when running fullscreen, with the catch that I have to turn off automatic graphics switching in the system preferences, otherwise the game renders wrong. (It seems like only the bottom left quarter of the game is visible. No idea what's going on there.)
- I tried various flags to SDL_SetVideoMode, with no effect. I also tried setting the color depth there to 32 instead of 16, producing trippy colors but no effect on performance.
- I tried disabling USE_HW in dr_flush and dr_textur, such that SDL_UpdateRect would be called on dirty tiles and SDL_Fill would never be called, matching the behavior of other platforms. This performed way worse, taking >1s to render each frame.
-
http://sdl.beuc.net/sdl.wiki/FAQ_MacOS_X_Windowed_Mode_is_slow seems *extremely* relevant :-)
A few resulting questions:
- What's with USE_HW? It's only defined on mac, and it appears that the other platforms just use software rendering (along with only updating dirty tiles instead of calling SDL_Fill). Does SDL software rendering simply perform better on the other platforms? (I certainly get fine performance on linux, though on an admittedly slightly lower-resolution monitor.)
- What's the status of the opengl backend? I was able to get it to compile with a handful of Makefile tweaks (locating the glew library with pkg-config; adding "-framework OpenGL"), and it seemed to work ok. (The news ticket had an awful flicker, but that went away if I forced pbo_able = false. Probably a straightforward bug in that branch of code.) It runs in hardware-accelerated mode, even windowed, and I get 25fps and 25ms idle time with it. Is there a backstory as to why it's not the default? Using OpenGL even for 2D rendering seems to be the right way to get good performance.