freedreno: replace fnv1a hash function with xxhash
authorDmitriy Nester <dmitriynester@gmail.com>
Thu, 27 Feb 2020 13:27:17 +0000 (15:27 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 25 May 2020 19:41:09 +0000 (19:41 +0000)
xxhash is faster than fnv1a in almost all circumstances, so we're
switching to it globally.

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

src/gallium/drivers/freedreno/a6xx/fd6_texture.c
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/ir3/ir3_cache.c

index a5396d939c89ce701dbeb447f569ba56ca4511fb..4338f1f1f6c763b4f82cce00ae018d1b18b482c0 100644 (file)
@@ -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
index 253b16e93d893a67fcf120643cba0f08c94d128a..329ed41fba363e34b9e9cdb7393cd234c10ebad7 100644 (file)
@@ -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;
 }
 
index ba96628bd4a0c91770f17210eb239b6c59e363d6..fdf81769f5a010353a86af334b479a4f58bec437 100644 (file)
@@ -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