[SDL] Looking for advices

Bille2 bille2 at free.fr
Wed Oct 31 01:26:00 PST 2001


"David Olofson" <david.olofson at reologica.se> a écrit dans le message news:
mailman.1004483114.2434.sdl at libsdl.org...
On Tuesday 30 October 2001 22:24, mewn wrote:
[...]
> with update_screen defined as :
>

Usualy, the best wait is with a semaphore:

int update=0;
whenever you are blitting, put
update=1;

then...
if (update)
{
    update_screen();
    update=0;
}

 Hope that will help. Jocelyn.

> int update_screen()
> {
> SDL_UpdateRect(screen,0,0,0,0);
> return(0);
> }

You're definitely going to burn plenty of CPU time in SDL_UpdateRect()
while copying to VRAM, at least on platforms without busmaster DMA
blitting from system RAM to VRAM.


> and my video_init :
> int video_init(void)
> {
> SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER);
> printf("start init\n");
> screen=SDL_SetVideoMode(WIDTH,HEIGHT,16,SDL_SWSURFACE);

What's the window size?


> I know it's a stupid test, but well I did it. With that I used 60% of
> my cpu. So now I'm afraid : I'm doing nothing and my code use nearly
> all my cpu.

You're pumping quite a bit of data from a software surface into VRAM -
that's hardly what I'd call "nothing". :-)


> My laptop is a 600Mhz, and well, I can't say it's SDL fault
> : sdlquake run smoothly...

That's probably because 1) it has a very fast software rasterizer, which
means it does just fine with the remaining 40% of CPU power, or 2) it's
using OpenGL for rendering, which means you get around this VRAM access
issue completely, even on Linux. (All textures are in VRAM or texture
RAM, or at worst, in the AGP aperture, from which fast busmaster DMA
transfers are possible. Yeah, even *that* works on Linux as well! ;-)


> Let me feed you with some data : I'm using a laptop with a cheap video
> card ( neomagic 3Mb ). The futur of the code is to play with ray
> casting.

What OS?


> What is wrong with the design ?

Nothing, really. It doesn't get more fun than that, "thanks" to the
crappy design of current video cards. :-/

However, you may try to avoid using software surfaces entirely, allowing
SDL to use h/w accelerated VRAM->VRAM blitting, which is available on
several targets. And then there's OpenGL...

And don't even think about rendering directly to VRAM for full screen
animation! That will *guarantee* poor performance on virtually all
targets. *heh*


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`-------------------------------------> http://olofson.net -'






More information about the SDL mailing list