diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index cf72d94687..54144dfe0b 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -109,15 +109,19 @@ static bool WriteTextureToPNG(png_imagep image, const std::string &filename, int } #endif -void TextureReplacer::NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int w, int h, ReplacedTextureFormat fmt) { +void TextureReplacer::NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, ReplacedTextureFormat fmt) { _assert_msg_(G3D, enabled_, "Replacement not enabled"); if (!g_Config.bSaveNewTextures) { // Ignore. return; } - char hashname[16 + 8 + 4 + 1] = {}; - snprintf(hashname, sizeof(hashname), "%016llx%08x.png", cachekey, hash); + char hashname[16 + 8 + 4 + 1 + 11 + 1] = {}; + if (level > 0) { + snprintf(hashname, sizeof(hashname), "%016llx%08x_%d.png", cachekey, hash, level); + } else { + snprintf(hashname, sizeof(hashname), "%016llx%08x.png", cachekey, hash); + } const std::string filename = basePath_ + hashname; // TODO: Check for ini ignored or aliased textures. diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index 7d758dfa2b..e155bd5b11 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -101,7 +101,7 @@ public: ReplacedTexture FindReplacement(u64 cachekey, u32 hash); - void NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int w, int h, ReplacedTextureFormat fmt); + void NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, ReplacedTextureFormat fmt); protected: bool LookupHashRange(u32 addr, int &w, int &h); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 309397873e..c281464647 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -1674,7 +1674,7 @@ void TextureCacheDX9::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &re if (replacer.Enabled()) { int bpp = dstFmt == D3DFMT_A8R8G8B8 ? 4 : 2; - replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash, entry.addr, pixelData, w * bpp, w, h, FromD3D9Format(dstFmt)); + replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash, entry.addr, pixelData, w * bpp, level, w, h, FromD3D9Format(dstFmt)); } } diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index cd3c6c1083..a7a8f7f579 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -1813,7 +1813,7 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &repla if (replacer.Enabled()) { int bpp = dstFmt == GL_UNSIGNED_BYTE ? 4 : 2; - replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash,entry.addr, pixelData, (useUnpack ? bufw : w) * bpp, w, h, FromGLESFormat(dstFmt, useBGRA)); + replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash,entry.addr, pixelData, (useUnpack ? bufw : w) * bpp, level, w, h, FromGLESFormat(dstFmt, useBGRA)); } } diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index e7741eca46..ce9d22298a 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -1348,7 +1348,7 @@ void TextureCacheVulkan::SetTexture(VulkanPushBuffer *uploadBuffer) { } else { LoadTextureLevel(*entry, (uint8_t *)data, stride, i, scaleFactor, dstFmt); if (replacer.Enabled()) { - replacer.NotifyTextureDecoded(cachekey, entry->fullhash, texaddr, data, stride, mipWidth, mipHeight, FromVulkanFormat(actualFmt)); + replacer.NotifyTextureDecoded(cachekey, entry->fullhash, texaddr, data, stride, i, mipWidth, mipHeight, FromVulkanFormat(actualFmt)); } } entry->vkTex->texture_->UploadMip(i, mipWidth, mipHeight, texBuf, bufferOffset, stride / bpp);