The Raspberry Pi only supports 32768 GPU memory allocations
see https://github.com/raspberrypi/firmware/issues/611
Each texture takes 2 allocs, so the max is around 16000, I've set it to 15000 to be safe
http://www.cplusplus.com/reference/list/list/erase/
cplusplus.com says that std::list::erase takes arguments
of const_iterator, but from build errors the Andriod
runtime says it takes non const iterators. gcc doesn't mind
removing the constness and it's not so important that they're
const, so I'm removing them.
I change the currently used 'map' of textures to a queue (implemented as a
list), and then remove from the end of the queue when textures need removing
from the cache, and adding to the beginning of the queue.
The other operation that is needed is moving the texture to the
front of the list whenever it is used, so that frequently used
textures are not deleted.
In order to make that last operation effecient, I created
a map of the locations of these textures, and keep that
properly updated. This makes the accessing of a texture still O(1).
Then, in order to have the iterators remain valid through insertions
and deletions, I needed to implement the queue as a list.
The map and queue implementation is a standard way to implement
an LRU cache, just FYI. Not something I thought of all on my own.
Fixes issue #744
We were calling glTexStorage2DMultisample with a 'samples' parameter of 0.
Reading the GL 4.4 spec, this is specifically forbidden, but the
documentation pages from Chronos were incorrectly stating that it was
allowed, so many implementations probably accept it. Mesa, the graphics
driver for many Linux cards has recently been corrected so that it emits
a warning and fails when glTexStorage2DMultisample is called with
samples=0. The current release works, but the next one will fail when
multisampling is turned off in this plugin (with multisampling turned
on, it will work the same as before).
The documentation pages from Kronos have since been updated to reflect
the GL spec (I put in a bug to them). You can see the proper
changes at this address
(https://www.opengl.org/wiki/GLAPI/glTexStorage2DMultisample).
Mupen64plus set GL_UNPACK_ALIGNMENT to 1 after TextureCache::init().
When TextureCache set GL_UNPACK_ALIGNMENT back to value obtained in init(),
it broke text in mupen64plus messages.
Pokemon Stadium missing ground texture #412 reveals the problem:
the game loads the same texture into tile0 and tile1.
The only difference is ShiftScale values.
Since the checksum is the same, the same CachedTexture is used for both tiles.
Shift scale correction ovrwrites ShiftScale for tile0 when tile1 is loaded.
Thus, texture coordinates for both tiles will be same.
Combiner uses (tile0-tile1)*env_a+shade. Since t0==t1, texture component is missing.
Solution: calculate ShiftScale for each tile right before use.
Fixed#412