[SDL] Function to load a BMP from a porton of a file

Latimerius pvl at uh.cz
Thu Oct 17 05:45:01 PDT 2002


On Thu, Oct 17, 2002 at 01:40:51PM +0100, Matthijs Hollemans wrote:

> 
> > > [...]  Then my game simply loads that whole bitmap
> > > into one SDL_Surface, and passes the rectangle
> > > corresponding to the current frame to SDL_BlitSurface
> >
> > Wouldn't it make for faster blitting if the image data were
> > stored in a contiguous memory region?
> 
> Hmm, I don't know how SDL or the typical video card implements
> blits, but I can remember that it did not matter to the Amiga
> blitter. Since blitter stands for "block image transferrer", I
> assume that current hardware blitters know how to blit rectangles,
> too. In other words, you tell the blitter to start at a certain
> offset in the surface (the x, y position), to blit a certain number
> of pixels (the width), to skip ahead a certain number of pixels
> (pitch minus width), and to repeat this a certain number of times
> (the height). Since all of this happens in hardware, it wouldn't be
> slower than copying a contiguous memory region. Of course, I am only
> guessing here, so you may want to take this with a grain of salt ;-)

Copying a contiguous block of memory should always be faster than
copying several smaller blocks, because a) you enjoy all benefits of
L1/L2 processor caches, b) everything is done in system bus bursts, and
c) the blitter proper is conceptually a single x86 instruction (one of
the string family prefixed with rep).  This is about as fast as you can
get when copying memory to memory.

Now the question is, does this matter in SDL at all?  Is it worth the
additional work to have one image per surface to make it easier for the
SDL low-level blitters?

	latimerius





More information about the SDL mailing list