[SDL] glSDL backend

David Olofson david at olofson.net
Fri Jan 7 10:37:22 PST 2005


On Friday 07 January 2005 18.20, Koshmaar wrote:
[...]
> Hmmm, I assumed that SWSURFACE's exist in system memory, and
> hardware ones, in video card's. If it's not true with glSDL (as I'm
> thinking now) then forgot what I've written :-]

glSDL is a bit odd in that regard. *All* surfaces (except for the 
display surface) are basically s/w surfaces. A so called h/w surface 
in glSDL is effectively a s/w surface with one or more textures bound 
to it. When you lock/modify/unlock such a surface, glSDL invalidates 
the texture(s), so that they're re-uploaded before they're used 
again. Blitting from one surface to another is just a s/w ==> s/w 
blit, followed by an invalidation of the target surface's textures.

That is;

 * surface ==> surface blits are fast (all in system RAM),
   however...

 * ...surface ==> surface blits cannot be accelerated by
   glSDL, so blending and stuff still relies on the CPU.

 * surface ==> display blits are extremely fast, except
   possibly the first blit after a texture invalidation.

 * display ==> surface and display ==> display blits can
   be pretty slow, since they usually involve CPU driven
   transfers to/from VRAM. (Driver dependent.)

 * Modifying the display surface directly is *extremely*
   slow, since glSDL will have to read all pixels from
   VRAM when you lock, and write them all back when you
   unlock. It doesn't help that there is no API for
   locking only part of a surface. (Sam threw in an
   extension for that in some version, but it was backed
   out again for several reasons. I believe one of them
   is that this feature is completely irrelevant to most
   backends, and is therefore hard to use correctly. Also,
   it's safer, more accurate and more efficient to do it
   on the application side.)

 * Unlike the DDraw backend, glSDL does not lose surfaces.
   It may lose textures, but you'll never know, as they're
   re-uploaded as soon as you blit to the screen again.


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---




More information about the SDL mailing list