[Pal-devel] Performance notes
Tomi Neste
flatlander at yellow-hut.com
Mon Jul 30 11:32:14 UTC 2007
Few notes about how to get the maximum graphics performance from (current
cvs) PAL:
First, if you don't notice any problems there is no need to worry about
performance. Using OpenGL for 2d graphics is likely to be very fast, even
when naively implemented and running on low-end hardware.
Functions like draw-circle, -line and -polygon are quite slow. Normally it
shouldn't be problem but if you want to do complex vector graphics it
could. This is mostly a design issuea since PAL is more oriented towards
bitmap graphics, if you need faster polygon primitives let me know the
details and I'll see what I can do.
DRAW-IMAGE and DRAW-IMAGE* should be _much_ faster in the cvs head version
than in the recent 1.0 release, given that a few conditions are met:
Internally draw-image/draw-image* works by "chaining" the draw operations
and as long as the chain is not cut performance is very good. If the chain
is repeatedly cut you will get lousy performance.
The chain is cut when:
- You call any graphics function except draw-image or draw-image*.
- You use any graphics state altering functions or macros (rotate, scale,
set-blend-mode, with-transformation etc.) except set-blend-color.
- You draw a different image than with the previous draw-image calls.
Internally PAL keeps count of the "current" image and whenever it changes
the chain gets cut.
- You use the :angle or :scale keywords in draw-image. That maybe fixed in
the future. (Also the alignment keywords cut the chain, due to my
laziness. I'll fix that soon.)
It's okay to have rotations and image changes but to get maximum
performance you need to make sure they don't regularly cut the chain.
So if you are only allowed to draw the same image again and again how you
get anything interesting on the screen? By tiling your graphics in one big
image and using the draw-image* you can avoid the need to change image and
in some cases you can use set-blend-color to change the color of image.
At some point I'm going to add a mechanism for cutting images to tiles
which then can be used interchangebly with regular images, that should
make avoiding image changes much easier.
About the examples/
- teddy.lisp is an especially bad example of chaining. Since the teddies
all have the same image drawing them would be very fast if not
a) when drawing the shadows with-transformation gets repeatedly called. It
would be better to translate the shadow position manually
b) the teddies need to be rotated.
- hares.lisp works suprisingly well altough it uses rotations and scaling.
It should be very fast if these wouldn't cut the chain :(
Again, if you don't have any perfomance problems just ignore what I just
wrote :)
--
tomppa
More information about the pal-devel
mailing list