Mesa (master): freedreno: replace fnv1a hash function with xxhash

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 25 19:56:39 UTC 2020


Module: Mesa
Branch: master
Commit: edd62619a1c455226a5bc972b024ea77debecfa5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=edd62619a1c455226a5bc972b024ea77debecfa5

Author: Dmitriy Nester <dmitriynester at gmail.com>
Date:   Thu Feb 27 15:27:17 2020 +0200

freedreno: replace fnv1a hash function with xxhash

xxhash is faster than fnv1a in almost all circumstances, so we're
switching to it globally.

Signed-off-by: Dmytro Nester <dmytro.nester at globallogic.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4020>

---

 src/gallium/drivers/freedreno/a6xx/fd6_texture.c      | 4 +---
 src/gallium/drivers/freedreno/freedreno_batch_cache.c | 8 +++++---
 src/gallium/drivers/freedreno/ir3/ir3_cache.c         | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
index a5396d939c8..4338f1f1f6c 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
@@ -359,9 +359,7 @@ static uint32_t
 key_hash(const void *_key)
 {
 	const struct fd6_texture_key *key = _key;
-	uint32_t hash = _mesa_fnv32_1a_offset_bias;
-	hash = _mesa_fnv32_1a_accumulate_block(hash, key, sizeof(*key));
-	return hash;
+	return XXH32(key, sizeof(*key), 0);
 }
 
 static bool
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index 253b16e93d8..329ed41fba3 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -28,6 +28,8 @@
 #include "util/set.h"
 #include "util/list.h"
 #include "util/u_string.h"
+#define XXH_INLINE_ALL
+#include "util/xxhash.h"
 
 #include "freedreno_batch.h"
 #include "freedreno_batch_cache.h"
@@ -98,9 +100,9 @@ static uint32_t
 key_hash(const void *_key)
 {
 	const struct key *key = _key;
-	uint32_t hash = _mesa_fnv32_1a_offset_bias;
-	hash = _mesa_fnv32_1a_accumulate_block(hash, key, offsetof(struct key, surf[0]));
-	hash = _mesa_fnv32_1a_accumulate_block(hash, key->surf, sizeof(key->surf[0]) * key->num_surfs);
+	uint32_t hash = 0;
+	hash = XXH32(key, offsetof(struct key, surf[0]), hash);
+	hash = XXH32(key->surf, sizeof(key->surf[0]) * key->num_surfs , hash);
 	return hash;
 }
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cache.c b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
index ba96628bd4a..fdf81769f5a 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cache.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
@@ -26,6 +26,8 @@
 
 #include "util/ralloc.h"
 #include "util/hash_table.h"
+#define XXH_INLINE_ALL
+#include "util/xxhash.h"
 
 #include "ir3_cache.h"
 #include "ir3_gallium.h"
@@ -35,9 +37,7 @@ static uint32_t
 key_hash(const void *_key)
 {
 	const struct ir3_cache_key *key = _key;
-	uint32_t hash = _mesa_fnv32_1a_offset_bias;
-	hash = _mesa_fnv32_1a_accumulate_block(hash, key, sizeof(*key));
-	return hash;
+	return  XXH32(key, sizeof(*key), 0);
 }
 
 static bool



More information about the mesa-commit mailing list