Major fps drop with SDL 1.3

Yesterday I recompiled a project I am working to make it use SDL 1.3 instead of 1.2.14 and my FPS dropped from over 80 to about 13. Is this normal? Should I rewrite my code to use SDL_Textures instead of SDL_Surfaces?

  1. Does this mean that all libraries created for SDL < 1.3 (like Guichan) will work sub-optimally also?
  2. It is possible to mix a SDL_Surface + SDL_BlitSurface code with SDL_Textures and SDL_RenderCopy?

I saw a similar thing recompiling my 1.2.14 based game with 1.3, the frame
rate dropped 50%. I switched to using the new API and the frame rate jumped
from 20 FPS to 400 FPS. I’d definitely recommend switching to the new API.

Sam is aware of the frame rate drop using the old API. I have provided him
with the code and assets for my game so he can see it firsthand. I’m sure
he will get to it when he has time.

KenFrom: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of hardcoder
Sent: Wednesday, January 06, 2010 6:16 AM
To: sdl at lists.libsdl.org
Subject: [SDL] major fps drop with SDL 1.3

Yesterday I recompiled a project I am working to make it use SDL 1.3 instead
of 1.2.14 and my FPS dropped from over 80 to about 13. Is this normal?
Should I rewrite my code to use SDL_Textures instead of SDL_Surfaces?

I already started to rewrite game rendering parts to use new API and as you say, for things that work already FPS is about 5x SDL 1.2 version and about 2x glSDL version. Seems that free lunch is not yet completely over :wink:

umh, is there a tutorial or a list of “what to do” for updating to the new
API?
beside this link
http://zeeky-h-bomb.blogspot.com/2008/10/sdl-window.htmlwhich can be
summarized in

SDL_VideoInit instead of SDL_Init
SDL_CreateWindow instad of SDL_SetVideoMode
SDL_CreateRenderer and SDL_SelectRenderer instead of (i don’t know)
SDL_RenderFill instad of SDL_FillRect

what other kind of documentation we have?
what would you add to the list of new api above?
VittorioOn Sun, Jan 10, 2010 at 12:31 PM, hardcoder wrote:

I already started to rewrite game rendering parts to use new API and as
you say, for things that work already FPS is about 5x SDL 1.2 version and
about 2x glSDL version. Seems that free lunch is not yet completely over [image:
Wink]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Samuel Goldwynhttp://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html

  • “I don’t think anyone should write their autobiography until after
    they’re dead.”

I finished updating my application to the new API and I now I think I mat not have been the right choice. The only renderer that produces correct output is d3d (creating opengl renderer crashes the app as reported in other post), and I actually hoped that user would be able to choose from 4 render drivers listed. On top of that FPS dropped by 50% (!!!) compared to SDL 1.2 + glSDL backend. I still hope that conversion was not a wasted time and this is just me doing something wrong. Is there any docs / faq / etc to point to efficient use of a renderer?

And how is this related to the thread?

Aveek Adhya wrote:> Hi all,

I am a newbie in SDL programming. I have got a decoded video frame. I just want to display the decoded frame using SDL. Is that sequence of API call (with appropriate parametes) enough for the display?

SDL_Init()
SDL_SetVideoMode()
SDL_CreateYUVOverlay()

SDL_LockYUVOverlay()
memcpy(…)
SDL_UnlockYUVOverlay()
SDL_DisplayYUVOverlay()

SDL_FreeSurface()
SDL_FreeYUVOverlay()
SDL_Quit()

Any sample example to display frame using overlay ?

Thanks…

Looks like the mail2forum software messed this up. I got his mail
correctly under the topic “[SDL] How to display a decoded frame?”

And how is this related to the thread?

Aveek Adhya wrote:

Hi all,

I am a newbie in SDL programming. I have got a decoded video frame. I
just want to display the decoded frame using SDL. Is that sequence of
APIOn Thu, 14 Jan 2010 07:17:43 -0800, “hardcoder” wrote:

call (with appropriate parametes) enough for the display?

SDL_Init()
SDL_SetVideoMode()
SDL_CreateYUVOverlay()

SDL_LockYUVOverlay()
memcpy(…)
SDL_UnlockYUVOverlay()
SDL_DisplayYUVOverlay()

SDL_FreeSurface()
SDL_FreeYUVOverlay()
SDL_Quit()

Any sample example to display frame using overlay ?

Thanks…


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

And again, it is under FPS issues with SDL 1.3.

Christoph Nelles wrote:> Looks like the mail2forum software messed this up. I got his mail

correctly under the topic “[SDL] How to display a decoded frame?”

On Thu, 14 Jan 2010 07:17:43 -0800, “hardcoder” <@hardcoder> wrote:

And how is this related to the thread?

Aveek Adhya wrote:

Hi all,

I am a newbie in SDL programming. I have got a decoded video frame. I
just want to display the decoded frame using SDL. Is that sequence of

API

call (with appropriate parametes) enough for the display?

SDL_Init()
SDL_SetVideoMode()
SDL_CreateYUVOverlay()

SDL_LockYUVOverlay()
memcpy(…)
SDL_UnlockYUVOverlay()
SDL_DisplayYUVOverlay()

SDL_FreeSurface()
SDL_FreeYUVOverlay()
SDL_Quit()

Any sample example to display frame using overlay ?

Thanks…


Christoph Nelles

E-Mail : evilazrael at evilazrael.de
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I also saw a 50% drop when using SDL 1.3, but with the old API. When I
switched to using Textures and the default renderer I saw a 10x speed
increase (to 400 FPS).From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of hardcoder
Sent: Thursday, January 14, 2010 5:06 AM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] major fps drop with SDL 1.3

I finished updating my application to the new API and I now I think I mat
not have been the right choice. The only renderer that produces correct
output is d3d (creating opengl renderer crashes the app as reported in other
post), and I actually hoped that user would be able to choose from 4 render
drivers listed. On top of that FPS dropped by 50% (!!!) compared to SDL 1.2

  • glSDL backend. I still hope that conversion was not a wasted time and this
    is just me doing something wrong. Is there any docs / faq / etc to point to
    efficient use of a renderer?

Any chance for a help here?

Are you using the new API, or just the new version of SDL? If you are using
SDL_Blit functions then you are using the old API and as I stated in a prior
post this results in a 50% slowdown. Sam is aware of the issue and I have
given him access to my game to demonstrate the issue. However, if you are
using the SDL_Render functions then you are using the new API and you should
see a dramatic increase in performance.

Here is a code snippet for my startup with the new SDL 1.3 video API:

  SDL_DisplayMode fullscreen_mode;



  SDL_zero( fullscreen_mode );



  fullscreen_mode.format = SDL_PIXELFORMAT_RGB24;



  m_nWindowID = SDL_CreateWindow(

        pName,

        SDL_WINDOWPOS_UNDEFINED,

        SDL_WINDOWPOS_UNDEFINED,

        g_nDisplayWidth,

        g_nDisplayHeight,

        SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL );



  if ( m_nWindowID )

  {

        int nResult;



        nResult = SDL_SetWindowDisplayMode( m_nWindowID,

&fullscreen_mode );

        SDL_ShowWindow( m_nWindowID );



        nResult = SDL_CreateRenderer(

m_nWindowID,-1,SDL_RENDERER_PRESENTCOPY );

        nResult = SDL_SelectRenderer( m_nWindowID );



        // Set the draw color to black

        nResult = SDL_SetRenderDrawColor( 0x00, 0x00, 0x00, 0xFF );



        // Fill the screen with black

        nResult = SDL_RenderClear();

            }

I do NOT call this, because if you do then it will block events. There is a
bug in the database with a sample to show this:

  // Do NOT call this or SDL will block all events

if ( cKS_Game::g_bCallVideoInit )

  {

        int nResult = SDL_VideoInit( NULL,0 );



        if ( nResult < 0 )

        {

              KS_LOGTRACE( "ERROR: Couldn't initialize video driver:

%s\n", SDL_GetError() );

              return false;

        }



        SDL_SelectVideoDisplay( 0 );

  }From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On

Behalf Of hardcoder
Sent: Thursday, January 14, 2010 1:20 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] major fps drop with SDL 1.3

Any chance for a help here?

Ken Rogoway wrote:

Are you using the new API, or just the new version of SDL? If you are using SDL_Blit functions then you are using the old API and as I stated in a prior post this results in a 50% slowdown. Sam is aware of the issue and I have given him access to my game to demonstrate the issue. However, if you are using the SDL_Render functions then you are using the new API and you should see a dramatic increase in performance.
Any chance for a help here?

As mentioned before, I already rewrote my in-progress game to the new API. My init code is virtually the same, and surfaces are now used as arguments to SDL_CreateTextureFromSurface. To be sure that I am not using anything deprecated I additionally defined SDL_NO_COMPAT. Also, as previously stated, it is not FPS drop compared to SDL 1.2 but to SDL 1.2 with glSDL as rendering backed, which I think is necessary to explain is an SDL drawing backed that uses OpenGL hardware driver to perform fake blitting same way it is now in SDL 1.3 (http://olofson.net/mixed.html). On my laptop (crap intel graphis) transition from glSDL to proper SDL 1.3 resulted in exact same FPS, on the other hand on my main machine with GeForce 9800 GTX+ fps dropped from 800 to 400.

Do you have some test cases for this? I have some time to look at
this, but I don’t see any bugs in bugzilla or any examples I can use
to reproduce these problems.

Thanks!On Thu, Jan 14, 2010 at 3:06 AM, hardcoder wrote:

I finished updating my application to the new API and I now I think I mat
not have been the right choice. The only renderer that produces correct
output is d3d (creating opengl renderer crashes the app as reported in other
post), and I actually hoped that user would be able to choose from 4 render
drivers listed. On top of that FPS dropped by 50% (!!!) compared to SDL 1.2

  • glSDL backend. I still hope that conversion was not a wasted time and this
    is just me doing something wrong. Is there any docs / faq / etc to point to
    efficient use of a renderer?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC