[SDL] CPU Usage
Joshua Oreman
oremanj at gmail.com
Thu Jul 28 16:11:51 PDT 2005
On 7/28/05, Diaa Sami <diaasami at yahoo.com> wrote:
> I've been using SDL for 2 weeks, so I'm somekind of a newbie with SDL.
> everything went fine until I noticed that my app uses about 80~90% (too
> much!) of the CPU, although I'm using a framerate limiter to limit the
> fps to 30.
>
> well, this is my problem, I want to lower the CPU usage of my app, it
> varies according to what's drawn on the screen, but I couldn't manage to
> get it below 40% (which I consider high)
>
> I've checked various apps/games, some using SDL, other using
> DirectDraw(coz I thought the problem is with SDL's implementation), and
> I found some DD and SDL apps which use little < 25% which's perfect.
> so I knew it can be achieved.
> [ ... ]
Why does it even matter how much CPU you're using? Is it making your
computer slower? Is the game running unsatisfactorily slow? If not,
then your CPU% is fine.
Possibly, the framerate limiter does a busy-wait loop instead of
sleeping -- this is fine, but that would account for the much higher
CPU%.
Unless it's connected to some other unsatisfactory occurrence, you can
safely stop worrying.
-- Josh
>
> one of the apps I checked was the testsprite sample that comes with SDL,
> I've checked the source code, and I found out that using
> SDL_UpdateRects() lowers the CPU usage much, but I can't use it
> everywhere in my app, sometimes I need to redraw the whole screen.
>
> I found that by only clearing the screen to black, and then updating, I
> get a relatively high CPU usage(60-70%)!
> here's the drawing part of the game loop.
> {
> SDL_FillRect(screen, NULL, black);
> SDL_Update(screen, 0, 0, 0, 0);
> SDL_framelimiterDelay(&fpsManager); // the framerate limiter
> }
>
> so could someone help me identify the solution?
> please don't tell me to use OpenGL, I already know OpenGL, and I know
> it'll solve the problem, but it's not suitable for my app because of
> some requirements.
>
> Info:
> Desktop configuration: 1024*768*32
> OS: Windows XP
> RAM: 512 MB
> VGA Card: RIVA TNT2 32 MB.
>
> SDL Video Mode: Windowed 640*480*24(I've tried also 32 bpp), I use
> SWSURFACE coz I have a fair amount of alpha blending.
> SDL_VideoInfo:
> Is it possible to create hardware surfaces : 1
> Is there a window manager available : 1
> Are hardware to hardware blits accelerated : 1
> Are hardware to hardware colorkey blits accelerated : 1
> Are hardware to hardware alpha blits accelerated : 0
> Are software to hardware blits accelerated : 1
> Are software to hardware colorkey blits accelerated : 1
> Are software to hardware alpha blits accelerated : 0
> Are color fills accelerated : 1
> Total amount of video memory in Kilobytes : 28688
> Driver Name: directx
>
> sorry for the long post and thanks for your effort.
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
More information about the SDL
mailing list