Some changes to the hashing by baby.lueshi

You may have to redump textures.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3188 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
death2droid 2009-05-09 02:04:04 +00:00
parent b277102796
commit b4ccf03967
1 changed files with 30 additions and 24 deletions

View File

@ -281,7 +281,9 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u32 hash_value;
u32 texID = address;
if (g_Config.bSafeTextureCache)
u32 texHash;
if (g_Config.bSafeTextureCache || g_Config.bHiresTextures || g_Config.bDumpTextures)
{
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, expandedHeight, tex_format, 0); // remove last arg
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
@ -298,6 +300,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
texID ^= TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
}
texHash = hash_value;
}
bool skip_texture_create = false;
@ -340,11 +344,33 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
}
}
}
PC_TexFormat dfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
//Make an entry in the table
TCacheEntry& entry = textures[texID];
PC_TexFormat dfmt;
if (g_Config.bHiresTextures)
{
//Load Custom textures
char texPathTemp[MAX_PATH];
int oldWidth = width;
int oldHeight = height;
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
dfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, temp);
if (dfmt != PC_TEX_FMT_NONE)
{
expandedWidth = width;
expandedHeight = height;
entry.size_in_bytes = sizeof(temp);
entry.scaleX = (float) width / oldWidth;
entry.scaleY = (float) height / oldHeight;
INFO_LOG(VIDEO, "loading custom texture from %s", texPathTemp);
}
}
if (dfmt == PC_TEX_FMT_NONE)
dfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
entry.hashoffset = 0;
//entry.paletteHash = hashseed;
@ -372,26 +398,6 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
glBindTexture(target, entry.texture);
}
u32 texHash = HashFNV(temp, entry.size_in_bytes);
if (g_Config.bHiresTextures)
{
//Load Custom textures
char texPathTemp[MAX_PATH];
int oldWidth = width;
int oldHeight = height;
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
PC_TexFormat customTex = HiresTextures::GetHiresTex(texPathTemp, &width, &height, temp);
if (customTex != PC_TEX_FMT_NONE)
{
entry.size_in_bytes = sizeof(temp);
entry.scaleX = (float) width / oldWidth;
entry.scaleY = (float) height / oldHeight;
INFO_LOG(VIDEO, "loading custom texture from %s", texPathTemp);
dfmt = customTex;
}
}
if (dfmt != PC_TEX_FMT_DXT1)
{
if (expandedWidth != width)
@ -465,7 +471,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
sprintf(szTemp, "%s/%s_%08x_%i.tga", FULL_DUMP_TEXTURES_DIR, ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
if (!File::Exists(szTemp))
{
SaveTexture(szTemp, target, entry.texture, width, height);
SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight);
}
}