[SDL] Surface Blitting Cost
William Brodie-Tyrrell
william at brodie-tyrrell.org
Wed Oct 18 05:42:40 PDT 2006
Stoned koala bears drooled eucalyptus spit in awe as Anton Mikhailov
said:
> from one surface to another, which would make it roughly O(N) where N is the
> number of pixels, but I dont know the constant factors and general real world
Yep, but the cost will depend on what format conversions have to be
performed. If the surfaces are the same format, it's basically memcpy;
if it has to convert, do colour-keying or alpha, it's gonna cost a lot
more.
Limiting factor in all cases is likely to be memory bandwidth,
particularly if one surface is on the video card, though this is a bit
of a guess on my part. Blits have good cache locality and the CPU is
more than capable of keeping up with the memory.
> Reason I ask is, I am in am doing an app where several images have to be
> combined together, rotated, then finally placed onto the screen. I have sprite
> sheets of the items I have to splice, and will be using OpenGL to rotate the
> final image. So I'm wondering if its cheaper to load all of them into OpenGL as
aha. So do it all in GL. Like Ryan says, it will be much much faster
as long as you have texturing hardware and don't have to repeatedly
download the sprites to the video card, i.e. your sprite sheets are
relatively static.
> textures (each sprite, not the sheet entirely) or use SDL to pick pieces of the
Personally I'd combine as many sprites onto a sheet as possible
(dynamically; will depend on max supported texture size of the device),
grouped by expected access pattern. That way, you reduce the number of
times you have to do a state-change, i.e. select a new texture.
> constantly changing) and only then rotate it.
If you're using GL, just rotate each sprite as you're drawing it; no
need to double-handle them. It's just one change to the modelview
matrix (you seem to have one single global rotation since you were
planning on blitting first then rotating the result of all the blits)
and everything will come out rotated for free.
(if people want me to stop polluting the list with GL stuff, do say so
and I'll try to reply in private to such questions)
--
William Brodie-Tyrrell
Carpe Diem - fish of the day.
<william at brodie-tyrrell.org>
http://www.brodie-tyrrell.org/
More information about the SDL
mailing list