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.
This commit is contained in:
degasus 2014-01-03 14:30:12 +01:00
parent 0f0a3cc509
commit 01351795f0
1 changed files with 10 additions and 2 deletions

View File

@ -255,11 +255,12 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign
char texPathTemp[MAX_PATH]; char texPathTemp[MAX_PATH];
unsigned int newWidth = 0; unsigned int newWidth = 0;
unsigned int newHeight = 0; unsigned int newHeight = 0;
u32 tex_hash_u32 = tex_hash & 0x00000000FFFFFFFFLL;
if (level == 0) 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 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; unsigned int required_size = 0;
PC_TexFormat ret = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, &required_size, texformat, temp_size, temp); 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 (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; width = newWidth;
height = newHeight; height = newHeight;
} }