mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-28 20:46:05 +00:00
Merge pull request #88 from unknownbrackets/texcache
Make the texcache evict less often
This commit is contained in:
commit
f71d82fc6e
@ -53,7 +53,7 @@ struct TexCacheEntry
|
||||
GLuint texture;
|
||||
};
|
||||
|
||||
typedef std::map<u32, TexCacheEntry> TexCache;
|
||||
typedef std::map<u64, TexCacheEntry> TexCache;
|
||||
static TexCache cache;
|
||||
|
||||
u32 tmpTexBuf32[1024 * 1024];
|
||||
@ -84,16 +84,15 @@ void TextureCache_Clear(bool delete_them)
|
||||
// Removes old textures.
|
||||
void TextureCache_Decimate()
|
||||
{
|
||||
// TODO: Need a better way to keep looping
|
||||
restart:
|
||||
for (TexCache::iterator iter = cache.begin(); iter != cache.end(); ++iter)
|
||||
for (TexCache::iterator iter = cache.begin(); iter != cache.end(); )
|
||||
{
|
||||
if (iter->second.frameCounter + TEXTURE_KILL_AGE < gpuStats.numFrames)
|
||||
{
|
||||
glDeleteTextures(1, &iter->second.texture);
|
||||
cache.erase(iter);
|
||||
goto restart;
|
||||
cache.erase(iter++);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -525,11 +524,15 @@ void PSPSetTexture()
|
||||
u8 level = 0;
|
||||
u32 format = gstate.texformat & 0xF;
|
||||
u32 clutformat = gstate.clutformat & 3;
|
||||
u32 clutaddr = GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2);
|
||||
|
||||
DEBUG_LOG(G3D,"Texture at %08x",texaddr);
|
||||
u8 *texptr = Memory::GetPointer(texaddr);
|
||||
u32 texhash = texptr ? *(u32*)texptr : 0;
|
||||
|
||||
TexCache::iterator iter = cache.find(texaddr);
|
||||
u64 cachekey = texaddr ^ clutaddr;
|
||||
cachekey |= (u64) texhash << 32;
|
||||
TexCache::iterator iter = cache.find(cachekey);
|
||||
if (iter != cache.end())
|
||||
{
|
||||
//Validate the texture here (width, height etc)
|
||||
@ -539,13 +542,13 @@ void PSPSetTexture()
|
||||
bool match = true;
|
||||
|
||||
//TODO: Check more texture parameters, compute real texture hash
|
||||
if (dim != entry.dim || entry.hash != *(u32*)texptr || entry.format != format)
|
||||
if (dim != entry.dim || entry.hash != texhash || entry.format != format)
|
||||
match = false;
|
||||
|
||||
//TODO: Check more clut parameters, compute clut hash
|
||||
if (match && (format >= GE_TFMT_CLUT4 && format <= GE_TFMT_CLUT32) &&
|
||||
(entry.clutformat != clutformat ||
|
||||
entry.clutaddr != GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2) ||
|
||||
entry.clutaddr != clutaddr ||
|
||||
entry.cluthash != Memory::Read_U32(entry.clutaddr)))
|
||||
match = false;
|
||||
|
||||
@ -572,7 +575,7 @@ void PSPSetTexture()
|
||||
TexCacheEntry entry;
|
||||
|
||||
entry.addr = texaddr;
|
||||
entry.hash = *(u32*)texptr;
|
||||
entry.hash = texhash;
|
||||
entry.format = format;
|
||||
entry.frameCounter = gpuStats.numFrames;
|
||||
|
||||
@ -835,5 +838,5 @@ void PSPSetTexture()
|
||||
//glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
cache[texaddr] = entry;
|
||||
cache[cachekey] = entry;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user