[SDL] faster way?

Karsten Laux klaux at student.uni-kl.de
Sat Aug 14 18:02:41 PDT 1999


Hello,

Frank Ramsay wrote:
> 
> I need a bit of help speeding something up.
> I'm porting a dos based isometric engine to SDL, and I got it running
> but I'm having a speed problem.  On my PII-450 I get 16 fps at 640x480
> and on my P1-150MMX laptop I get 4.8 fps at 640x480.  Needless to say
> that
> is lousy performance.  So I really need some ideas on how to speed this
> thing up.
> 
> Here is the basic design:
> The display is set to 640x480x8bpp (SDL_HWSURFACE)
> the drawing functions draw to a back buffer (not an SDL surface, but
> a big old chunk o'memory pointed to by char *virtual_screen
> when the drawing is done it calls my wrapper function
> display_screen(char *buffer)
> I'm not worried about the map-drawing function right now because
> I know it is not optimized at all.
> I did some checking and the main loop runs at about 150,000 times/sec
> if neither the draw function of screen update function are called.  I
> also had these functions return right away (so I could find out how
> much time was lost with the function call overhead) and the main loop
> was still running at over 140,000 times/sec.
> If I just put in the display_screen function, it drops to around
> 39 fps. (at 640x480x8bpp) and if I comment out the SDL_UpdateRects
> call it jumps up to around 440 fps, but that is useless because I
> don't see anything that way...
> 

>From my experience with XWindows and running SDL in a window, I would
advise you to avoid
updates of the whole screen. The 39 fps you get for your app only
updating the screen is not that bad.
The graphical isometric frontend for worldforge
(http://www.worldforge.org), which I am developing, tries to figure out
which parts of the screen actually need an screen update and so it
updates only the needed parts. (if you only need to update half of the
screen you get 80fps ...) Well if I need to scroll your screen, there is
(currently ... ) no way but to update the whole screen, but scrolling
even with 20fps does not look that bad.

Using your own backbuffer is quite a good idea, especially if you plan
any alpha blits, because readaccess to the "real" screenbuffer (either
videoram or shared mem) is always slower compared to main memory access.


just my 0.02 euro.

-- 
Karsten-O. Laux           
klaux at student.uni-kl.de
http://www.rhrk.uni-kl.de/~klaux
UIN 21614933 (Bert)



More information about the SDL mailing list