freedreno/ir3: fix kill scheduling
[mesa.git] / src / util / hash_table.c
index 9d98270886867e088b369fe691d53f46a104653c..6bac4a4f68e8832bb9979fba33e5c25cfd5e6f55 100644 (file)
@@ -50,6 +50,9 @@
 #include "main/hash.h"
 #include "fast_urem_by_const.h"
 
+#define XXH_INLINE_ALL
+#include "xxhash.h"
+
 static const uint32_t deleted_key_value;
 
 /**
@@ -549,8 +552,25 @@ _mesa_hash_table_random_entry(struct hash_table *ht,
 uint32_t
 _mesa_hash_data(const void *data, size_t size)
 {
-   return _mesa_fnv32_1a_accumulate_block(_mesa_fnv32_1a_offset_bias,
-                                          data, size);
+   return XXH32(data, size, 0);
+}
+
+uint32_t
+_mesa_hash_int(const void *key)
+{
+   return XXH32(key, sizeof(int), 0);
+}
+
+uint32_t
+_mesa_hash_uint(const void *key)
+{
+   return XXH32(key, sizeof(unsigned), 0);
+}
+
+uint32_t
+_mesa_hash_u32(const void *key)
+{
+   return XXH32(key, 4, 0);
 }
 
 /** FNV-1a string hash implementation */
@@ -568,6 +588,32 @@ _mesa_hash_string(const void *_key)
    return hash;
 }
 
+uint32_t
+_mesa_hash_pointer(const void *pointer)
+{
+   uintptr_t num = (uintptr_t) pointer;
+   return (uint32_t) ((num >> 2) ^ (num >> 6) ^ (num >> 10) ^ (num >> 14));
+}
+
+bool
+_mesa_key_int_equal(const void *a, const void *b)
+{
+   return *((const int *)a) == *((const int *)b);
+}
+
+bool
+_mesa_key_uint_equal(const void *a, const void *b)
+{
+
+   return *((const unsigned *)a) == *((const unsigned *)b);
+}
+
+bool
+_mesa_key_u32_equal(const void *a, const void *b)
+{
+   return *((const uint32_t *)a) == *((const uint32_t *)b);
+}
+
 /**
  * String compare function for use as the comparison callback in
  * _mesa_hash_table_create().