Jump to content


Photo

Framerate With Sdl


  • Please log in to reply
12 replies to this topic

#1 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 202 posts

Posted 06 May 2011 - 12:08 PM

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-s...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!!


#2 Joshff

Joshff

    X-S Enthusiast

  • Members
  • 17 posts

Posted 08 May 2011 - 04:22 PM

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;



#3 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 202 posts

Posted 19 May 2011 - 11:30 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!

#4 weinerschnitzel

weinerschnitzel

    X-S Senior Member

  • Dev/Contributor
  • PipPip
  • 279 posts
  • Xbox Version:v1.0
  • 360 version:v4.0 (jasper)

Posted 20 May 2011 - 02:36 AM

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

#5 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 595 posts
  • Gender:Male
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v5.0 (360S - trinity)

Posted 20 May 2011 - 03:15 AM

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.

#6 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 202 posts

Posted 20 May 2011 - 10:36 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 sad.gif


#7 weinerschnitzel

weinerschnitzel

    X-S Senior Member

  • Dev/Contributor
  • PipPip
  • 279 posts
  • Xbox Version:v1.0
  • 360 version:v4.0 (jasper)

Posted 20 May 2011 - 06:56 PM

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.

#8 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 595 posts
  • Gender:Male
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v5.0 (360S - trinity)

Posted 21 May 2011 - 05:14 AM

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

#9 freakdave

freakdave

    X-S X-perience

  • Dev/Contributor
  • PipPip
  • 472 posts
  • Location:Europe
  • Interests:PROGRAMMING,XBOX...
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 27 May 2011 - 07:33 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...

Edited by freakdave, 27 May 2011 - 07:40 PM.


#10 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 202 posts

Posted 29 May 2011 - 12:38 AM

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!! smile.gif

#11 freakdave

freakdave

    X-S X-perience

  • Dev/Contributor
  • PipPip
  • 472 posts
  • Location:Europe
  • Interests:PROGRAMMING,XBOX...
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 28 October 2011 - 05:33 PM

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.

#12 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 202 posts

Posted 31 October 2011 - 05:39 PM

QUOTE(freakdave @ Oct 28 2011, 05:33 PM) View Post

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.


Thank you very much for your answer, freakdave!

But I don't understand the last thing that you said. You mean that the fastest option is using SDL_DOUBLEBUF and SDL_HWSURFACE... but later you say that the best in Xbox is using SDL_SWSURFACE for a better framerate. uhh.gif

I am disconcerned... I was assuming that the fastest option gives the better framerate, doesn't it?

#13 weinerschnitzel

weinerschnitzel

    X-S Senior Member

  • Dev/Contributor
  • PipPip
  • 279 posts
  • Xbox Version:v1.0
  • 360 version:v4.0 (jasper)

Posted 01 November 2011 - 12:20 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users