summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/TextureDecoder.cpp
diff options
context:
space:
mode:
authorRodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com>2010-02-03 14:13:03 +0000
committerRodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com>2010-02-03 14:13:03 +0000
commite98a273b5472af8b8d4a1d1e055c03856356c289 (patch)
tree43020836c30a13733ed3ff97467105d2cb069c54 /Source/Core/VideoCommon/Src/TextureDecoder.cpp
parent9e2bbec47f402f584536434dbdf3353fb817b8e7 (diff)
fixes for my last commit:
chage the global format of the screenshots to bmp, is correctly supported by both plugins and is faster. reverted the changes in safe texture cache, will try to make them more stable then commit them, this should fix compilation in linux and macand error introduced in MP games corrected all the issues commented by ector, thanks for the comments alway is good that the code is revised by others to find missed spots. please report any remaining issue to solve them. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5001 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/TextureDecoder.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/TextureDecoder.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
index d49633609c..c6db5582bb 100644
--- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp
+++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
@@ -88,7 +88,7 @@ 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_GetTlutHash(const u8* src, int len)
{
//char str[40000], st[20]; str[0]='\0';for (int i=0;i<len;i++){sprintf(st,"%02x ",src[i]);strcat(str,st);}
u64 hash = 0xbeefbabe1337c0de;
@@ -111,6 +111,36 @@ u64 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texf
}
return hash;
}
+*/
+
+u32 TexDecoder_GetTlutHash(const u8* src, int len)
+{
+ //char str[40000], st[20]; str[0]='\0';for (int i=0;i<len;i++){sprintf(st,"%02x ",src[i]);strcat(str,st);}
+ u32 hash = 0xbeefbabe;
+ for (int i = 0; i < len / 4; i ++) {
+ hash = _rotl(hash, 7) ^ ((u32 *)src)[i];
+ hash += 7; // to add a bit more entropy/mess in here
+ }
+ return hash;
+}
+
+u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat, u32 seed)
+{
+ int sz = TexDecoder_GetTextureSizeInBytes(width, height, texformat);
+ u32 hash = seed ? seed : 0x1337c0de;
+ 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;
+}
int TexDecoder_GetBlockWidthInTexels(u32 format)
{