Sign in to follow this  
Nightbird1225

SDL in windowed mode: performance poor

Recommended Posts

Hello all, My app runs at ~50-60 fps in fullscreen mode and only ~15-20 in windowed mode. Anyone have any ideas as to why this might be happening? I am using software surfaces and I notice the performance is the same on my friends' laptops.

Share this post


Link to post
Share on other sites
Try hardware surfaces and see what happens.

I'm thinking maybe SDL is having a problem with software rendering with windowing using DirectDraw, so it falls back on GDI (as far as i know)..so yeah it would be molasses slow.

Try hardware surfaces in full and windowed mode and post your framerates.

Share this post


Link to post
Share on other sites
Already tried (sorry should have mentioned it). I started with the textures in HWSURFACES and my frame rate was about 10% higher in Full and 2%(maybe) in windowed. I switched over to software thinking that somehow I had too much GDI in the video card frame buffer to allow effective Hardware surfaces. It turns out not to make much difference. Thanks for the hint though, it is exactly what I would have thought too. I am trying to nail this down before I put in any more of the complex systems, and I am trying to run it with Software surfaces now to target the low end systems.

-Nightbird

Share this post


Link to post
Share on other sites
If you're running in windowed mode and use a different display mode (bit depth, etc) than your desktop, every time the screen is updated, the data on your window has to be converted to the same format as your desktop. That is a very time consuming.

If you want windowed mode to run fast too, then you have to set it to the same bit depth as your desktop.
screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
does it for you (note the bpp=0). Then do SDL_DisplayFormat for all your surfaces that are going to be blitted.

That should give you a small speed increase.

-Richardo

Share this post


Link to post
Share on other sites
I guess that's why I didn't say 100% :)

Check out this article where it says:
Quote:
The options tell SDL that I want a full screen (SDL_FULLSCREEN), double buffered (SDL_DOUBLEBUF), hardware surface (SDL_HWSURFACE). The part that isn't obvious is that on my desktop system if I want a hardware surface, it has to be full screen. I can't get a hardware surface for a window. This is one of those things that is operating system and device driver specific. Some systems let you have a hardware surface for a window. Even if you can get a hardware surface for a window, you may not be able to get a double buffered hardware surface for a window.


The article is for Linux but I have the problem in Windows XP Pro, Radeon 9600 256 (not XT, not PRO). I cannot get a hardware surface in a window. Googling gives pages of results where people are having the same issue. I think it's safe to assume that it's a bad idea to do hardware/double buffering with SDL in a Window if you plan on distributing your game.

Share this post


Link to post
Share on other sites
Well thanks for the reply and the article. Now I can prove to the boss-man that a windowed game won't work. I originally spec'ed the game out to be fullscreen as default anyhow. I just wish I knew why even with software textures the windowed and fullscreen modes have such a different frame rate. I guess that could be attributed to the (likely) lack of getting Double Buffering in a window, but I wish I knew for sure.

Thanks
-Nightbird

Share this post


Link to post
Share on other sites
This is true but if the performance is horrible on my machine then likely the low-end user who wants to run in windowed mode is likely to encounter an unplayable game. I will leave it in there for now and make a decision after I finish the fullscreen engine.

Thanks for your help.
-Nightbird

Share this post


Link to post
Share on other sites
Is the performance horrible on your machine if you explicitly use a SWSURFACE? I meant that if the user wants to run the game in windowed mode, use SWSURFACE and if the user wants to run it in fullscreen mode use HWSURFACE.

Share this post


Link to post
Share on other sites
Well in SW or HW surfaces in full I get about the same performance but in Windowed it is irrelevant because my machine will only give it SW surfaces. The performance on my machine is horrible only in Window mode. In Full with SW I get about 45-50 fps and with HW I get 50+ so I don't have a problem running SW on my system as long as I keep it FULLSCREEN. I am planning on always using HWSURFACES and, as that article stated, if their machine can have HW in window mode then they will get it otherwise they will default back to SW, and this is fine. I am thinking that the performance in window mode is due to the lack of double buffering, as it is not allowed on most machines in window mode, as per that article. So that is likely where the performance hit is taking place.

-Nightbird

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this