summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2022-07-22 08:52:26 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2022-08-01 10:07:27 -0700
commit17c554c1656fc6ea2df1463a97628379954b65ed (patch)
tree9eb9c08e2fb6216c44ad4c783ca0bd7fe1242ed8 /Source/Core/VideoCommon
parentfb45ed3981d4aaaaa55fcd16686bba68fed2c4f1 (diff)
Common/Hash: use zlib-ng for adler32. small cleanups.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/NativeVertexFormat.h32
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp2
2 files changed, 29 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/NativeVertexFormat.h b/Source/Core/VideoCommon/NativeVertexFormat.h
index 94dc1a0fa2..55e1a40178 100644
--- a/Source/Core/VideoCommon/NativeVertexFormat.h
+++ b/Source/Core/VideoCommon/NativeVertexFormat.h
@@ -7,7 +7,6 @@
#include <functional> // for hash
#include "Common/CommonTypes.h"
-#include "Common/Hash.h"
#include "VideoCommon/CPMemory.h"
// m_components
@@ -79,10 +78,37 @@ namespace std
template <>
struct hash<PortableVertexDeclaration>
{
- size_t operator()(const PortableVertexDeclaration& decl) const
+ // Implementation from Wikipedia.
+ template <typename T>
+ u32 Fletcher32(const T& data) const
{
- return Common::HashFletcher(reinterpret_cast<const u8*>(&decl), sizeof(decl));
+ static_assert(sizeof(T) % sizeof(u16) == 0);
+
+ auto buf = reinterpret_cast<const u16*>(&data);
+ size_t len = sizeof(T) / sizeof(u16);
+ u32 sum1 = 0xffff, sum2 = 0xffff;
+
+ while (len)
+ {
+ size_t tlen = len > 360 ? 360 : len;
+ len -= tlen;
+
+ do
+ {
+ sum1 += *buf++;
+ sum2 += sum1;
+ } while (--tlen);
+
+ sum1 = (sum1 & 0xffff) + (sum1 >> 16);
+ sum2 = (sum2 & 0xffff) + (sum2 >> 16);
+ }
+
+ // Second reduction step to reduce sums to 16 bits
+ sum1 = (sum1 & 0xffff) + (sum1 >> 16);
+ sum2 = (sum2 & 0xffff) + (sum2 >> 16);
+ return (sum2 << 16 | sum1);
}
+ size_t operator()(const PortableVertexDeclaration& decl) const { return Fletcher32(decl); }
};
} // namespace std
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index 07bbe0aa2e..b17f80ba6f 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -94,8 +94,6 @@ TextureCacheBase::TextureCacheBase()
HiresTexture::Init();
- Common::SetHash64Function();
-
TMEM::InvalidateAll();
}