xboxscene.org forums

Author Topic: Framerate With Sdl  (Read 1062 times)

hcf

  • Archived User
  • Full Member
  • *
  • Posts: 115
Framerate With Sdl
« on: May 06, 2011, 05:08:00 AM »

I am planning to port a Windows game made with SDL, to the Xbox. So, I have made a first attempt using libSDLx with OpenXDK, but the framerate is horrible (around 7 FPS). I use 640x480 resolution and I must refresh the full screen in every frame (think that it's a SuperMarioBros-like game with scrolling background). Of course if I only refresh a little section of the screen, the FPS boosts up, but it is not possible to do this in this kind of game. And I think that 7 FPS is too much slow...

Do anyone has worked with libSDLx and knows what framerate could be expected? For example, if I use libSDLx with XDK (and not OpenXDK), would I get a better performance? Also, I saw a post of the year 2006 where friedgold said that he made a patch to correct this issue:

http://forums.xbox-scene.com/index.php?sho...amp;mode=linear

But that patch is not online anymore. In any case, I guess that this patch was added to the libSDLx distribution lately, correct?

So, I would need some help from someone who has worked with SDL on the Xbox. What is the way to get a best framerate? XDK is better than OpenXDK? Any option of the Video Mode? (I think that I have tried with all the options...) Any patch for libSDLx to upgrade the framerate?
Thank you very much!!
Logged

Joshff

  • Archived User
  • Newbie
  • *
  • Posts: 13
Framerate With Sdl
« Reply #1 on: May 08, 2011, 09:22:00 AM »

I don't know about OpenXDK but if you try libSDLx and have the same framerate problems, try to disable the vsync:

edit src/video/xbox/SDL_xboxvideo.c

and change

D3D_PP.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;

to

D3D_PP.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

Logged

hcf

  • Archived User
  • Full Member
  • *
  • Posts: 115
Framerate With Sdl
« Reply #2 on: May 19, 2011, 04:30:00 AM »

Thank you very much for your answer.  A friend accepted to test my SDL code in XDK, and it worked at 60 FPS! So it seems that you were right: maybe the libSDLx (for XDK) is faster than the precompiled SDL that comes with OpenXDK...
Thanks!
Logged

weinerschnitzel

  • Archived User
  • Full Member
  • *
  • Posts: 218
Framerate With Sdl
« Reply #3 on: May 19, 2011, 07:36:00 PM »

Can your friend test your port with HDTV using Hyper_Eye's work on libSDLx?
Logged

Hyper_Eye

  • Recovered User
  • Sr. Member
  • *
  • Posts: 366
Framerate With Sdl
« Reply #4 on: May 19, 2011, 08:15:00 PM »

It's not so much a matter of libSDL for XDK being faster than libSDL for openxdk as it is that sound and video code performs better when built with XDK than it does when built with openxdk. Openxdk definitely would benefit from further development.
Logged

hcf

  • Archived User
  • Full Member
  • *
  • Posts: 115
Framerate With Sdl
« Reply #5 on: May 20, 2011, 03:36:00 AM »

Thanks to everybody for your kind responses. It seems that Hyper_Eye is right, and XDK builts more optimized code than OpenXDK, although OpenXDK works well and it can be valid if you want to build games that don't require a high performance.

@weinerschnitzel: I don't have a HD TV, and my friend neither. But if you send me a code prepared to be compiled with Visual Studio .NET 2003 and XDK, I can send the code to my friend and I guess that he can compile it for you. After that, we can send you the XBE resulting file and you can test it in your HD TV. Sorry that I cannot offer you any more  (IMG:style_emoticons/default/sad.gif)
Logged

weinerschnitzel

  • Archived User
  • Full Member
  • *
  • Posts: 218
Framerate With Sdl
« Reply #6 on: May 20, 2011, 11:56:00 AM »

With directx it would be a matter of changing the back buffer to 1280x720, setting some video flags to enable it, then just making sure the game outputs to that resolution.

With Hyper_Eye's changes to libSDLx, you should just be able to change the resolution like you normally would and if its supported you'll be able to use it. He could probably tell you exactly what to change. I on the other hand haven't played with an SDL front end, so I would have to toy around with it before giving you a definitive answer.

I'll test it for you on HDTV no problem.
Logged

Hyper_Eye

  • Recovered User
  • Sr. Member
  • *
  • Posts: 366
Framerate With Sdl
« Reply #7 on: May 20, 2011, 10:14:00 PM »

The HDTV stuff as it relates to libSDLx in my repository is well described here: http://forums.xbox-scene.com/index.php?s=&...t&p=4673445
Logged

freakdave

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 284
Framerate With Sdl
« Reply #8 on: May 27, 2011, 12:33:00 PM »

Well, i experienced the same FPS problem in my SDL application that i am developing for the XBOX. These lines fixed it for me, i am getting constant 58 fps (instead of 5-6 fps) now.

This should be somewhere in the video initialization code:
CODE

screen = SDL_SetVideoMode(640, 480, 16, SDL_FULLSCREEN | SDL_SWSURFACE);


Search for SDL_Flip(), replace it with:
CODE
SDL_UpdateRect(screen, 0, 0, 0, 0);


Hope this helps...

This post has been edited by freakdave: May 27 2011, 07:40 PM
Logged

hcf

  • Archived User
  • Full Member
  • *
  • Posts: 115
Framerate With Sdl
« Reply #9 on: May 28, 2011, 05:38:00 PM »

Thank you very much Freakdave, I will definitely test that. It's very interesting because it is supposed that "SDL_Flip()" does the same that "SDL_UpdateRect(screen, 0, 0, 0, 0)"... Are you talking about XDK or OpenXDK?

Besides, I was not awared that using SDL_SWSURFACE was better than SDL_HWSURFACE in a Xbox. Again, is this related to XDK or OpenXDK?

Thank you very much for those tips!!  (IMG:style_emoticons/default/smile.gif)
Logged

freakdave

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 284
Framerate With Sdl
« Reply #10 on: October 28, 2011, 10:33:00 AM »

QUOTE
Thank you very much Freakdave, I will definitely test that. It's very interesting because it is supposed that "SDL_Flip()" does the same that "SDL_UpdateRect(screen, 0, 0, 0, 0)"... Are you talking about XDK or OpenXDK?

Besides, I was not awared that using SDL_SWSURFACE was better than SDL_HWSURFACE in a Xbox. Again, is this related to XDK or OpenXDK?


I am talking about libSDLx (XDK) in both cases:

SDL_Flip() is meant to be used with the SDL_DOUBLEBUF flag, it swaps the display (background, foreground) buffers for systems that support double buffering.

On systems that do not support double buffering, SDL_Flip will do the same as SDL_UpdateRect(screen, 0, 0, 0, 0).

In terms of speed, you should use SDL_HWSURFACE in combination with the SDL_DOUBLEBUF flag -> http://sdl.beuc.net/...DL_SetVideoMode

HOWEVER, for a decent frame rate on the XBOX (XDK, libSDLx) you might want to use the setup provided in my last post.
Logged

weinerschnitzel

  • Archived User
  • Full Member
  • *
  • Posts: 218
Framerate With Sdl
« Reply #11 on: October 31, 2011, 05:20:00 PM »

I think he is referring to using single buffer over a double buffer. SDL_HWSURFACE should be more appetizing than SDL_SWSURFACE regardless of using a front/back buffer.
Logged