GP2X Question About Sdl_setvideomode With Paeryn's Lib


joyrider

Active Member
Joined
Mar 29, 2006
Messages
589
Age
43
Website
www.willemssoft.be
hi,

I've been looking through some source code of other games and i noted that all of them pass SDL_SWSURFACE as a flag to sdl_setvideomode. However i've always been passing SDL_HWSURFACE to it. Now my question is am i doing this wrong or not. You see when i use SDL_HWSURFACE i get a kernel panic after some time and have been unable to fix it !. However if i use SDL_SWSURFACE i don't get a kernel panic and i'm starting to think i always did it wrong or not ?

The main reason why i'm passing SDL_HWSURFACE is speed ! when i don't limit my game (dynamate) and let it run to its maximum speed, i'm getting 100 fps. (I do have to create a buffer where i blit everything to before blitting it to the screen in order to counter act the flickering issues which comes from it). When i pass SDL_SWSURFACE i only get 40 fps. I'm guessing this has something to do with vsync etc.

I thought the screen surface was always an HWSURFACE with paeryn's sdl but why does it make such a huge diffrence then with passing SDL_SWSURFACE. Shouldn't it be the same if it's ALways an hwsurface ?

i also like to know if passing SDL_HWSURFACE to sdl_setvideo is "allowed" on the gp2x with paeryn's libs.

cheers.
 
joyrider said:
hi,

I've been looking through some source code of other games and i noted that all of them pass SDL_SWSURFACE as a flag to sdl_setvideomode. However i've always been passing SDL_HWSURFACE to it. Now my question is am i doing this wrong or not. You see when i use SDL_HWSURFACE i get a kernel panic after some time and have been unable to fix it !. However if i use SDL_SWSURFACE i don't get a kernel panic and i'm starting to think i always did it wrong or not ?

The main reason why i'm passing SDL_HWSURFACE is speed ! when i don't limit my game (dynamate) and let it run to its maximum speed, i'm getting 100 fps. (I do have to create a buffer where i blit everything to before blitting it to the screen in order to counter act the flickering issues which comes from it). When i pass SDL_SWSURFACE i only get 40 fps. I'm guessing this has something to do with vsync etc.

I thought the screen surface was always an HWSURFACE with paeryn's sdl but why does it make such a huge diffrence then with passing SDL_SWSURFACE. Shouldn't it be the same if it's ALways an hwsurface ?

i also like to know if passing SDL_HWSURFACE to sdl_setvideo is "allowed" on the gp2x with paeryn's libs.

cheers.
I use
CODE

poResources->Screen = SDL_SetVideoMode( poConfig->ScreenWidth, poConfig->ScreenHeight, poConfig->ScreenBpp, SDL_HWSURFACE | SDL_DOUBLEBUF );



I also thought sdl_surfaces were always made to be hardware, althought you have to make them have the same parameters using

CODE

optimizedImage = SDL_DisplayFormat( loadedImage ); //Create an optimized surface
 
Last edited by a moderator:
ah damn so it is ok to use it. Too bad i can't seem to find any sources of a game that uses external joysticks & tv out on the cradle as well as hw_surfaces (with sdl). will browse some more through the archive. in the mean time i'm stuck on using sw_surfaces.
 
You can use either, really. It all depends on your use. I know that when I did the work to switch STPPC2x from software (which it's always used) to hardware, there was hardly any difference but when I optimised the use of the software surfaces, that made 10x the difference. So from my point of view I didn't see that it was worth the effort to use HW surfaces, especially seeing as tiny subtle bugs started to surface only in HW mode.

Pick one before you start a project and stick with it, but software is more than adequate (as you say yourself, you're getting 40fps anyway). There's a lot of stuff to weigh up, such as which memory you are using, how much of it you are using (double-buffering = two screens worth before you start), how much battery life is affected (although software will use "more CPU", it's hard to properly profile power usage because hardware just shifts certain jobs to other parts of the chip/other chips etc.), etc. In the end, it's all pretty much the same and software is "good enough" and a little simpler to understand which is why most simple projects use it.

If you're on the edge of your game falling over because of an over-used CPU then hardware is worth trying but otherwise there's little to choose between the two.
 
Just found this nice explanation on the SDL site while looking for something else:

Note: Use SDL_SWSURFACE if you plan on doing per-pixel manipulations, or blit surfaces with alpha channels, and require a high framerate. When you use hardware surfaces (SDL_HWSURFACE), SDL copies the surfaces from video memory to system memory when you lock them, and back when you unlock them. This can cause a major performance hit. (Be aware that you may request a hardware surface, but receive a software surface. Many platforms can only provide a hardware surface when using SDL_FULLSCREEN.) SDL_HWSURFACE is best used when the surfaces you'll be blitting can also be stored in video memory.
 
Back
Top