Don't invalidate textures based on the clutaddr.
The cluthash should be sufficient, and this is less to pass around.
This commit is contained in:
parent
7dd0d242e2
commit
5a81bfd1fb
2 changed files with 6 additions and 12 deletions
|
@ -120,12 +120,10 @@ void TextureCache::Invalidate(u32 addr, int size, GPUInvalidationType type) {
|
||||||
for (TexCache::iterator iter = cache.begin(), end = cache.end(); iter != end; ++iter) {
|
for (TexCache::iterator iter = cache.begin(), end = cache.end(); iter != end; ++iter) {
|
||||||
u32 texAddr = iter->second.addr;
|
u32 texAddr = iter->second.addr;
|
||||||
u32 texEnd = iter->second.addr + iter->second.sizeInRAM;
|
u32 texEnd = iter->second.addr + iter->second.sizeInRAM;
|
||||||
// Clear if either the addr or clutaddr is in the range.
|
|
||||||
bool invalidate = (texAddr >= addr && texAddr < addr_end) || (texEnd >= addr && texEnd < addr_end);
|
bool invalidate = (texAddr >= addr && texAddr < addr_end) || (texEnd >= addr && texEnd < addr_end);
|
||||||
invalidate = invalidate || (addr >= texAddr && addr < texEnd) || (addr_end >= texAddr && addr_end < texEnd);
|
invalidate = invalidate || (addr >= texAddr && addr < texEnd) || (addr_end >= texAddr && addr_end < texEnd);
|
||||||
|
|
||||||
invalidate = invalidate || (iter->second.clutaddr >= addr && iter->second.clutaddr < addr_end);
|
|
||||||
|
|
||||||
if (invalidate) {
|
if (invalidate) {
|
||||||
if ((iter->second.status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_RELIABLE) {
|
if ((iter->second.status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_RELIABLE) {
|
||||||
// Clear status -> STATUS_HASHING.
|
// Clear status -> STATUS_HASHING.
|
||||||
|
@ -769,7 +767,7 @@ inline bool TextureCache::TexCacheEntry::Matches(u16 dim2, u32 hash2, u8 format2
|
||||||
return dim == dim2 && hash == hash2 && format == format2 && maxLevel == maxLevel2;
|
return dim == dim2 && hash == hash2 && format == format2 && maxLevel == maxLevel2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TextureCache::TexCacheEntry::MatchesClut(bool hasClut, u8 clutformat2, u32 clutaddr2) {
|
inline bool TextureCache::TexCacheEntry::MatchesClut(bool hasClut, u8 clutformat2) {
|
||||||
if (!hasClut)
|
if (!hasClut)
|
||||||
return true;
|
return true;
|
||||||
return clutformat == clutformat2;
|
return clutformat == clutformat2;
|
||||||
|
@ -817,7 +815,7 @@ void TextureCache::SetTexture() {
|
||||||
|
|
||||||
u64 cachekey = texaddr;
|
u64 cachekey = texaddr;
|
||||||
|
|
||||||
u32 clutformat, clutaddr, cluthash;
|
u32 clutformat, cluthash;
|
||||||
if (hasClut) {
|
if (hasClut) {
|
||||||
if (gstate_c.clutChanged) {
|
if (gstate_c.clutChanged) {
|
||||||
UpdateCurrentClut();
|
UpdateCurrentClut();
|
||||||
|
@ -825,12 +823,10 @@ void TextureCache::SetTexture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
clutformat = gstate.clutformat & 3;
|
clutformat = gstate.clutformat & 3;
|
||||||
clutaddr = GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2);
|
|
||||||
cluthash = GetCurrentClutHash();
|
cluthash = GetCurrentClutHash();
|
||||||
cachekey |= (u64)cluthash << 32;
|
cachekey |= (u64)cluthash << 32;
|
||||||
} else {
|
} else {
|
||||||
clutformat = 0;
|
clutformat = 0;
|
||||||
clutaddr = 0;
|
|
||||||
cluthash = 0;
|
cluthash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,7 +873,7 @@ void TextureCache::SetTexture() {
|
||||||
//Validate the texture here (width, height etc)
|
//Validate the texture here (width, height etc)
|
||||||
|
|
||||||
int dim = gstate.texsize[0] & 0xF0F;
|
int dim = gstate.texsize[0] & 0xF0F;
|
||||||
bool match = entry->Matches(dim, texhash, format, maxLevel) && entry->MatchesClut(hasClut, clutformat, clutaddr);
|
bool match = entry->Matches(dim, texhash, format, maxLevel) && entry->MatchesClut(hasClut, clutformat);
|
||||||
bool rehash = (entry->status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_UNRELIABLE;
|
bool rehash = (entry->status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_UNRELIABLE;
|
||||||
bool doDelete = true;
|
bool doDelete = true;
|
||||||
|
|
||||||
|
@ -915,7 +911,7 @@ void TextureCache::SetTexture() {
|
||||||
TexCache::iterator secondIter = secondCache.find(secondKey);
|
TexCache::iterator secondIter = secondCache.find(secondKey);
|
||||||
if (secondIter != secondCache.end()) {
|
if (secondIter != secondCache.end()) {
|
||||||
TexCacheEntry *secondEntry = &secondIter->second;
|
TexCacheEntry *secondEntry = &secondIter->second;
|
||||||
if (secondEntry->Matches(dim, texhash, format, maxLevel) && secondEntry->MatchesClut(hasClut, clutformat, clutaddr)) {
|
if (secondEntry->Matches(dim, texhash, format, maxLevel) && secondEntry->MatchesClut(hasClut, clutformat)) {
|
||||||
// Reset the numInvalidated value lower, we got a match.
|
// Reset the numInvalidated value lower, we got a match.
|
||||||
if (entry->numInvalidated > 8) {
|
if (entry->numInvalidated > 8) {
|
||||||
--entry->numInvalidated;
|
--entry->numInvalidated;
|
||||||
|
@ -995,7 +991,6 @@ void TextureCache::SetTexture() {
|
||||||
|
|
||||||
|
|
||||||
entry->clutformat = clutformat;
|
entry->clutformat = clutformat;
|
||||||
entry->clutaddr = clutaddr;
|
|
||||||
entry->cluthash = cluthash;
|
entry->cluthash = cluthash;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ private:
|
||||||
u8 clutformat;
|
u8 clutformat;
|
||||||
u32 cluthash;
|
u32 cluthash;
|
||||||
u16 dim;
|
u16 dim;
|
||||||
u32 clutaddr;
|
|
||||||
u32 texture; //GLuint
|
u32 texture; //GLuint
|
||||||
int invalidHint;
|
int invalidHint;
|
||||||
u32 fullhash;
|
u32 fullhash;
|
||||||
|
@ -98,7 +97,7 @@ private:
|
||||||
bool tClamp;
|
bool tClamp;
|
||||||
|
|
||||||
bool Matches(u16 dim2, u32 hash2, u8 format2, int maxLevel2);
|
bool Matches(u16 dim2, u32 hash2, u8 format2, int maxLevel2);
|
||||||
bool MatchesClut(bool hasClut, u8 clutformat2, u32 clutaddr2);
|
bool MatchesClut(bool hasClut, u8 clutformat2);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Decimate(); // Run this once per frame to get rid of old textures.
|
void Decimate(); // Run this once per frame to get rid of old textures.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue