From 01351795f01d113a587fe51c904cdba84536f230 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 3 Jan 2014 14:30:12 +0100 Subject: [PATCH] TextureCache: Warn for invalid custom textures At the moment, custom textures with: - invalid mipmap size - invalid aspect ratio - non-fractional scaling factors are allowed. But they can't be loaded fine by the backend, so generate a warning if someone trys to load them. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 8555bd736d..a3224bcf08 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -255,11 +255,12 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign char texPathTemp[MAX_PATH]; unsigned int newWidth = 0; unsigned int newHeight = 0; + u32 tex_hash_u32 = tex_hash & 0x00000000FFFFFFFFLL; if (level == 0) - sprintf(texPathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat); + sprintf(texPathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat); else - sprintf(texPathTemp, "%s_%08x_%i_mip%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat, level); + sprintf(texPathTemp, "%s_%08x_%i_mip%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat, level); unsigned int required_size = 0; PC_TexFormat ret = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, &required_size, texformat, temp_size, temp); @@ -275,6 +276,13 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign if (ret != PC_TEX_FMT_NONE) { + if (level > 0 && (newWidth != width || newHeight != height)) + ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. This mipmap layer _must_ be %dx%d.", newWidth, newHeight, texPathTemp, width, height); + if (newWidth * height != newHeight * width) + ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. The aspect differs from the native size %dx%d.", newWidth, newHeight, texPathTemp, width, height); + if (newWidth % width || newHeight % height) + WARN_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. Please use an integer upscaling factor based on the native size %dx%d.", newWidth, newHeight, texPathTemp, width, height); + width = newWidth; height = newHeight; }