The frameNum assignment in std3D_UpdateFrameCount at
|
pTexture->frameNum = std3D_frameCount; |
is immediately undone by
std3D_RemoveTextureFromCacheList, which means if the GPU is low on VRAM and a texture needs to be uploaded, it will sometimes pick textures which were uploaded in the same frame with the same size, causing the texture pair to constantly thrash between evicted by
std3D_PurgeTextureCache and uploaded by
std3D_AddToTextureCache (visually, this looks like random surface textures flickering back and forth) between two textures.
Discovered this bug on accident because I borrowed the code for my DSi port, moving the assignment to after std3D_AddTextureToCacheList makes the LRU cache function as expected.