Re: [AD] - MMX Linear clear |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
varobert@xxxxxxxxxx writes:
> I haven't been receiving anything from [AD} in a while (including my own
> posts), so I wonder if I've been kicked out of something.
Not that I know of...
> Well, back to business: I've written an MMX version of linear_clear_16
Cool. What sort of performance boost do you get from this?
> (will do the same for other color depths later), but I'd like to know: how
> do I make clear_to_color() use that routine instead of the non MMX version
The easy way would be just to include it as an alternative version of the
existing function (in iblit8.s), and check the value of cpu_mmx to decide
which one to use (and make sure to put the MMX code inside a #ifdef
ALLEGRO_MMX, so people using pre-MMX assembler versions can still compile
Allegro).
A more comprehensive method would be to make a new VTABLE structure that
points at your MMX drawing code (as an alternative to the one in vtable8.c),
add it to the list in vtable.c, add a field to the GFX_VTABLE structure to
indicate whether it requires MMX or not, and change the _get_vtable()
routine in graphics.c to return an appropriate version of the vtable, in
case there is more than one for the same color depth, one with and one
without MMX support. That's the clean way to do it, but in this case I tend
to think that it is overkill, and it would be best just to handle this
within the single existing function.
> If I ever get around to do the same for blit(), would I need to change
> something else for Allegro to use my function ?
Blitting is a problem, because it is used for displaying the mouse cursor,
which means it has to be interrupt safe, and you can't use MMX (or indeed
any FPU code) in an interrupt context. So this would need some way to detect
when it is being used inside an interrupt and know to avoid the MMX in that
case. But the first thing is to write the code and see how much faster it
goes: when someone tried this before (I forget who, sorry), they reported
that it didn't give any useful speed boost, and it's only worth worrying
about if it really does make things substantially faster...
--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."