Skip to content
Permalink
Browse files

Use xxHash instead of CityHash, it's faster.

At least on Windows it's definitely got the edge.
  • Loading branch information...
unknownbrackets committed Aug 17, 2013
1 parent 5acbbe7 commit 52f1de8f1d37080ea2669b6527b9c49dd628b991
Showing with 7 additions and 7 deletions.
  1. +2 −3 GPU/GLES/TextureCache.cpp
  2. +5 −4 GPU/GLES/TransformPipeline.cpp
@@ -26,6 +26,7 @@
#include "GPU/GLES/Framebuffer.h"
#include "Core/Config.h"

#include "ext/xxhash.h"
#include "native/ext/cityhash/city.h"

#ifdef _M_SSE
@@ -892,9 +893,7 @@ void TextureCache::UpdateCurrentClut() {
// If not, we're going to hash random data, which hopefully doesn't cause a performance issue.
const u32 clutExtendedBytes = clutTotalBytes_ + clutBaseBytes;

// QuickClutHash is not quite good enough apparently.
// clutHash_ = QuickClutHash((const u8 *)clutBufRaw_, clutExtendedBytes);
clutHash_ = CityHash32((const char *)clutBufRaw_, clutExtendedBytes);
clutHash_ = XXH32((const char *)clutBufRaw_, clutExtendedBytes, 0xC0108888);

// Avoid a copy when we don't need to convert colors.
if (clutFormat != GE_CMODE_32BIT_ABGR8888) {
@@ -27,6 +27,7 @@

#include "native/gfx_es2/gl_state.h"
#include "native/ext/cityhash/city.h"
#include "ext/xxhash.h"

#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@@ -1034,14 +1035,14 @@ u32 TransformDrawEngine::ComputeHash() {
// It is really very expensive to check all the vertex data so often.
for (int i = 0; i < numDrawCalls; i++) {
if (!drawCalls[i].inds) {
fullhash += CityHash32((const char *)drawCalls[i].verts, vertexSize * drawCalls[i].vertexCount);
fullhash += XXH32((const char *)drawCalls[i].verts, vertexSize * drawCalls[i].vertexCount, 0x1DE8CAC4);
} else {
// This could get seriously expensive with sparse indices. Need to combine hashing ranges the same way
// we do when drawing.
fullhash += CityHash32((const char *)drawCalls[i].verts + vertexSize * drawCalls[i].indexLowerBound,
vertexSize * (drawCalls[i].indexUpperBound - drawCalls[i].indexLowerBound));
fullhash += XXH32((const char *)drawCalls[i].verts + vertexSize * drawCalls[i].indexLowerBound,
vertexSize * (drawCalls[i].indexUpperBound - drawCalls[i].indexLowerBound), 0x029F3EE1);
int indexSize = (dec_->VertexType() & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT ? 2 : 1;
fullhash += CityHash32((const char *)drawCalls[i].inds, indexSize * drawCalls[i].vertexCount);
fullhash += XXH32((const char *)drawCalls[i].inds, indexSize * drawCalls[i].vertexCount, 0x955FD1CA);
}
}

0 comments on commit 52f1de8

Please sign in to comment.
You can’t perform that action at this time.