Merge pull request #14883 from unknownbrackets/texcache

In lazy hashing mode, assume videos never match
This commit is contained in:
Henrik Rydgård 2021-09-19 19:46:44 +02:00 committed by GitHub
commit 7f021624e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -160,6 +160,13 @@ static int Replace_memcpy() {
NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, tag.c_str(), tag.size());
NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, tag.c_str(), tag.size());
// It's pretty common that games will copy video data.
if (tag == "ReplaceMemcpy/VideoDecode" || tag == "ReplaceMemcpy/VideoDecodeRange") {
if (bytes == 512 * 272 * 4) {
gpu->NotifyVideoUpload(destPtr, bytes, 512, GE_FORMAT_8888);
}
}
return 10 + bytes / 4; // approximation
}
@ -203,6 +210,13 @@ static int Replace_memcpy_jak() {
NotifyMemInfo(MemBlockFlags::READ, srcPtr, bytes, tag.c_str(), tag.size());
NotifyMemInfo(MemBlockFlags::WRITE, destPtr, bytes, tag.c_str(), tag.size());
// It's pretty common that games will copy video data.
if (tag == "ReplaceMemcpy/VideoDecode" || tag == "ReplaceMemcpy/VideoDecodeRange") {
if (bytes == 512 * 272 * 4) {
gpu->NotifyVideoUpload(destPtr, bytes, 512, GE_FORMAT_8888);
}
}
return 5 + bytes * 8 + 2; // approximation. This is a slow memcpy - a byte copy loop..
}

View File

@ -539,7 +539,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
if (PPGeIsFontTextureAddress(texaddr)) {
// It's the builtin font texture.
entry->status = TexCacheEntry::STATUS_RELIABLE;
} else if (g_Config.bTextureBackoffCache) {
} else if (g_Config.bTextureBackoffCache && !IsVideo(texaddr)) {
entry->status = TexCacheEntry::STATUS_HASHING;
} else {
entry->status = TexCacheEntry::STATUS_UNRELIABLE;
@ -1724,6 +1724,15 @@ void TextureCacheCommon::DeleteTexture(TexCache::iterator it) {
bool TextureCacheCommon::CheckFullHash(TexCacheEntry *entry, bool &doDelete) {
int w = gstate.getTextureWidth(0);
int h = gstate.getTextureHeight(0);
bool isVideo = IsVideo(entry->addr);
// Don't even check the texture, just assume it has changed.
if (isVideo && g_Config.bTextureBackoffCache) {
// Attempt to ensure the hash doesn't incorrectly match in if the video stops.
entry->fullhash = (entry->fullhash + 0xA535A535) * 11 + (entry->fullhash & 4);
return false;
}
u32 fullhash;
{
PROFILE_THIS_SCOPE("texhash");
@ -1731,7 +1740,7 @@ bool TextureCacheCommon::CheckFullHash(TexCacheEntry *entry, bool &doDelete) {
}
if (fullhash == entry->fullhash) {
if (g_Config.bTextureBackoffCache) {
if (g_Config.bTextureBackoffCache && !isVideo) {
if (entry->GetHashStatus() != TexCacheEntry::STATUS_HASHING && entry->numFrames > TexCacheEntry::FRAMES_REGAIN_TRUST) {
// Reset to STATUS_HASHING.
entry->SetHashStatus(TexCacheEntry::STATUS_HASHING);