Implement dynamic hardware palette sizing.

The HardwarePalette will now grow its palette buffer and texture in power-of-2 increments. This avoids it having to allocate memory for a full 256x256 texture up front. In practice the default mods use 22 or 23 palettes so a 32x256 texture is used. This means both the buffer and texture save neatly on memory. Additionally, HardwarePalette.ApplyModifiers sees a nice speedup as it has to transfer a much smaller amount of memory from the buffer to the texture.

To facilitate this change, the MaxPalettes constant is no more. Instead the PaletteReference deals with the calculation of the index and this is passed into the appropriate methods.
This commit is contained in:
RoosterDragon
2015-01-07 21:08:48 +00:00
parent 40c9d0a47d
commit 53f06ba093
7 changed files with 42 additions and 32 deletions

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Graphics
PaletteReference CreatePaletteReference(string name)
{
var pal = palette.GetPalette(name);
return new PaletteReference(name, palette.GetPaletteIndex(name), pal);
return new PaletteReference(name, palette.GetPaletteIndex(name), pal, palette);
}
string cursorName;