From e93e777ffb941af612805ee438db5b8c0e5b5c73 Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Mon, 8 Feb 2010 23:23:04 +0000 Subject: second try to implement a more correct safe texture cache, implemented full hashing of tlut textures as they are the more problematic, this should solve virtually all the problems with characters in all the games that have them. sorry to tell but this will bring a speed drop, so let you decide if this change stay or not.( used the fastest open source hash algorithm i know) do not apply full hashing to other format because it kills the performance. for popular request added 9x SSAA believe me will kill your graphic card even if is the best but the image quality is exceptional. as always please test and let me know the results. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5034 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/VideoCommon/Src/TextureDecoder.cpp | 89 +++++++++++++------------- 1 file changed, 45 insertions(+), 44 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureDecoder.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index c6db5582bb..1cf39c17ea 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -88,57 +88,58 @@ int TexDecoder_GetTextureSizeInBytes(int width, int height, int format) return (width * height * TexDecoder_GetTexelSizeInNibbles(format)) / 2; } -/*u64 TexDecoder_GetTlutHash(const u8* src, int len) +u64 TexDecoder_GetFullHash(const u8 *key, int len, u64 seed) { - //char str[40000], st[20]; str[0]='\0';for (int i=0;i> r; + k *= m; + + h ^= k; + h *= m; } - return hash; -} -u64 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat, u32 seed) + const u8 * data2 = (const u8*)data; + + switch(len & 7) + { + case 7: h ^= u64(data2[6]) << 48; + case 6: h ^= u64(data2[5]) << 40; + case 5: h ^= u64(data2[4]) << 32; + case 4: h ^= u64(data2[3]) << 24; + case 3: h ^= u64(data2[2]) << 16; + case 2: h ^= u64(data2[1]) << 8; + case 1: h ^= u64(data2[0]); + h *= m; + }; + + h ^= h >> r; + h *= m; + h ^= h >> r; + + return h; +} + +u64 TexDecoder_GetFastHash(const u8 *src, int len, u64 seed) { - int len = TexDecoder_GetTextureSizeInBytes(width, height, texformat); - u64 hash = seed ? seed : 0xbeefbabe1337c0de; - int step = len / 29 / 8; + u64 hash = seed ? seed : 0x1337c0debeefbabe; + int step = (len / 8) / 37; if (!step) step = 1; for (int i = 0; i < len / 8; i += step) { - hash = _rotl(hash, 17) ^ ((u64 *)src)[i]; - } - return hash; -} -*/ - -u32 TexDecoder_GetTlutHash(const u8* src, int len) -{ - //char str[40000], st[20]; str[0]='\0';for (int i=0;i