diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 6842e2490d40..aa2ecc022ad0 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -301,6 +301,7 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, VFSBackend *dir, bool isOverri // Multiplies sizeInRAM/bytesPerLine in XXHASH by 0.5. options->Get("reduceHash", &reduceHash_, reduceHash_); options->Get("ignoreMipmap", &ignoreMipmap_, ignoreMipmap_); + options->Get("skipLastDXT1Blocks128x64", &skipLastDXT1Blocks128x64_, skipLastDXT1Blocks128x64_); if (reduceHash_ && hash_ == ReplacedTextureHash::QUICK) { reduceHash_ = false; ERROR_LOG(Log::TexReplacement, "Texture Replacement: reduceHash option requires safer hash, use xxh32 or xxh64 instead."); @@ -506,14 +507,17 @@ u32 TextureReplacer::ComputeHash(u32 addr, int bufw, int w, int h, bool swizzled } const u8 *checkp = Memory::GetPointerUnchecked(addr); + + float reduceHashSize = 1.0f; if (reduceHash_) { reduceHashSize = LookupReduceHashRange(w, h); // default to reduceHashGlobalValue which default is 0.5 } + if (bufw <= w) { // We can assume the data is contiguous. These are the total used pixels. const u32 totalPixels = bufw * h + (w - bufw); - const u32 sizeInRAM = (textureBitsPerPixel[fmt] * totalPixels) / 8 * reduceHashSize; + u32 sizeInRAM = (textureBitsPerPixel[fmt] * totalPixels) / 8 * reduceHashSize; // Sanity check: Ignore textures that are at the end of RAM. if (Memory::MaxSizeAtAddress(addr) < sizeInRAM) { @@ -521,6 +525,12 @@ u32 TextureReplacer::ComputeHash(u32 addr, int bufw, int w, int h, bool swizzled return 0; } + // Hack for Yu Gi Oh texture hashing problem. See issue #19714 + if (skipLastDXT1Blocks128x64_ && fmt == GE_TFMT_DXT1 && w == 128 && h == 64) { + // Skip the last few blocks as specified. + sizeInRAM -= 8 * skipLastDXT1Blocks128x64_; + } + switch (hash_) { case ReplacedTextureHash::QUICK: return StableQuickTexHash(checkp, sizeInRAM); diff --git a/GPU/Common/TextureReplacer.h b/GPU/Common/TextureReplacer.h index d71c36b09c7c..ea70bc09ea0b 100644 --- a/GPU/Common/TextureReplacer.h +++ b/GPU/Common/TextureReplacer.h @@ -149,8 +149,8 @@ class TextureReplacer { bool ignoreAddress_ = false; bool reduceHash_ = false; bool ignoreMipmap_ = false; + int skipLastDXT1Blocks128x64_ = 0; - float reduceHashSize = 1.0f; // default value with reduceHash to false float reduceHashGlobalValue = 0.5f; // Global value for textures dump pngs of all sizes, 0.5 by default but can be set in textures.ini double lastTextureCacheSizeGB_ = 0.0; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 9449ed5190af..1520358cadaf 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -652,8 +652,6 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } // Format might be wrong in lowMemoryMode_, so don't save. if (plan.saveTexture && !lowMemoryMode_) { - INFO_LOG(Log::G3D, "Calling NotifyTextureDecoded %08x", entry->addr); - // When hardware texture scaling is enabled, this saves the original. int w = dataScaled ? mipWidth : mipUnscaledWidth; int h = dataScaled ? mipHeight : mipUnscaledHeight; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 428301a83d0a..68772aeb3807 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -2089,6 +2089,7 @@ UI::EventReturn DeveloperToolsScreen::OnLoggingChanged(UI::EventParams &e) { } UI::EventReturn DeveloperToolsScreen::OnRunCPUTests(UI::EventParams &e) { + // TODO: If game is loaded, don't do anything. #if !PPSSPP_PLATFORM(UWP) RunTests(); #endif