[Scummvm-devel] cost of palette changes

Max Horn max at quendi.de
Tue Jun 29 00:02:36 CEST 2010


Hi there,

partial palette updates are no worse or better than full palette updates. Just use them.

Palette update in general, though, on modern machines with true color output are more expensive than on old hardware with real hardware palette support, by the nature of it. Back then, any graphic output would go through that hardware palette; to change a palette entry, you only had to modify the entry in the hardware palette, and be done.
On modern systems, we have to emulate this, by re-rendering the *complete* screen surface. Depending on the system on runs on, this may be a problem if you do it a lot (meaning many dozen or hundred time a second)

While in theory, one only needs to update the pixels which are using the color(s), in practice it is impractical to keep track of that data, and even if you can do it, it will in almost all cases be worse than just biting the bullet and doing a fullscreen update (due to extra overhead, caching issues etc.).

Anyway, you only need to keep this in mind:
* Palette updates on modern systems are not "free" like you may remember from your old Amiga/Atari/IBM PC/...
* Still, it's not so bad, unless you do many, many *many* palette changes per second, and run on low end hardware such as a Nintendo DS
* However, in most cases your user won't be able to see more than 30 FPS anyway, so in the end it should be possible to do palette changes just fine

As Johannes already pointed out, the best way to be sure your code works well is to test on low end devices (or let somebody do it for you). No way around that. But I still would recommend to not try any premature optimizations in this area. 

Cheers,
Max



More information about the Scummvm-devel mailing list