diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-03-02 23:01:18 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-03-02 23:01:18 +0000 |
| commit | 9ef42aefac405e7f4eea922980c1934d2c1c635d (patch) | |
| tree | 374e051c24a8c02f807d9c2fab96a9ab0f9fa2ae /Source/Core/VideoCommon/Src/TextureDecoder.cpp | |
| parent | 18cf664b9df59f14d34335558eb134464facdad4 (diff) | |
Revert to slightly tweaked version of "old" safe texture hash. Hopefully fixes issue 636. Does somewhat break pokemon colosseum w/ safe texture hash, but that games works fine with the unsafe texture hash.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2532 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/TextureDecoder.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureDecoder.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index de532707cd..e161cf5b08 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -77,29 +77,17 @@ u32 TexDecoder_GetTlutHash(const u8* src, int len) u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat, u32 seed) { - // Notes (mb2): A relative important mess in data is needed for a good hash. The safest way to satisfy this would be - // to perform the hash on the whole texture. But since it kills perf we use some assuptions for speed: - // -First assumption: texture borders don't carry more different data than the rest of the texture. We skip few - // texels on the edges. - // -Second assumption: consecutives lines may not differ that much. We skip some lines regularly. - // -Third assumption: User info (messy datas), in textures, should be either always centered or at the beginning. - // So we can stop hashing near the center. - - // very tweakable (Pokemon Colesseum texts are pretty good test cases, especially short ones) - const int edgeSkip = 3; - const int colSkip = 3; - const int rowSkip = 5; - - const int rowEnd = (width - edgeSkip)/4; - const int byteWidth = TexDecoder_GetTextureSizeInBytes(width, 1, texformat); - const int colEnd = height - edgeSkip; + int sz = TexDecoder_GetTextureSizeInBytes(width, height, texformat); u32 hash = seed ? seed : 0x1337c0de; - - for (int y = edgeSkip; y < colEnd; y += colSkip) - { - for (int x = edgeSkip; x < rowEnd; x += rowSkip) - { - hash = _rotl(hash, 17) ^ ((u32 *)src)[x+byteWidth*y]; + if (sz < 2048) { + for (int i = 0; i < sz / 4; i += 13) { + hash = _rotl(hash, 19) ^ ((u32 *)src)[i]; + } + return hash; + } else { + int step = sz / 23 / 4; + for (int i = 0; i < sz / 4; i += step) { + hash = _rotl(hash, 19) ^ ((u32 *)src)[i]; } } return hash; |
