#include "compiler/nir_types.h"
#include "compiler/shader_enums.h"
#include "compiler/shader_info.h"
+#define XXH_INLINE_ALL
+#include "util/xxhash.h"
#include <stdio.h>
#ifndef NDEBUG
}
-#define HASH(hash, data) _mesa_fnv32_1a_accumulate((hash), (data))
+#define HASH(hash, data) XXH32(&(data), sizeof(data), hash)
static uint32_t
hash_src(uint32_t hash, const nir_src *src)
}
} else {
unsigned size = instr->def.num_components * sizeof(*instr->value);
- hash = _mesa_fnv32_1a_accumulate_block(hash, instr->value, size);
+ hash = XXH32(instr->value, size, hash);
}
return hash;
hash = HASH(hash, instr->dest.ssa.bit_size);
}
- hash = _mesa_fnv32_1a_accumulate_block(hash, instr->const_index,
- info->num_indices
- * sizeof(instr->const_index[0]));
+ hash = XXH32(instr->const_index, info->num_indices * sizeof(instr->const_index[0]), hash);
return hash;
}
hash_instr(const void *data)
{
const nir_instr *instr = data;
- uint32_t hash = _mesa_fnv32_1a_offset_bias;
+ uint32_t hash = 0;
switch (instr->type) {
case nir_instr_type_alu:
static uint32_t
hash_deref(const void *void_deref)
{
- uint32_t hash = _mesa_fnv32_1a_offset_bias;
+ uint32_t hash = 0;
for (const nir_deref_instr *deref = void_deref; deref;
deref = nir_deref_instr_parent(deref)) {
switch (deref->deref_type) {
case nir_deref_type_var:
- return _mesa_fnv32_1a_accumulate(hash, deref->var);
+ return XXH32(&deref->var, sizeof(deref->var), hash);
case nir_deref_type_array:
continue; /* Do nothing */
case nir_deref_type_struct:
- hash = _mesa_fnv32_1a_accumulate(hash, deref->strct.index);
+ hash = XXH32(&deref->strct.index, sizeof(deref->strct.index), hash);
continue;
default:
* the order of the hash table walk is deterministic */
struct entry_key *key = (struct entry_key*)key_;
- uint32_t hash = _mesa_fnv32_1a_offset_bias;
+ uint32_t hash = 0;
if (key->resource)
- hash = _mesa_fnv32_1a_accumulate(hash, key->resource->index);
+ hash = XXH32(&key->resource->index, sizeof(key->resource->index), hash);
if (key->var) {
- hash = _mesa_fnv32_1a_accumulate(hash, key->var->index);
+ hash = XXH32(&key->var->index, sizeof(key->var->index), hash);
unsigned mode = key->var->data.mode;
- hash = _mesa_fnv32_1a_accumulate(hash, mode);
+ hash = XXH32(&mode, sizeof(mode), hash);
}
for (unsigned i = 0; i < key->offset_def_count; i++)
- hash = _mesa_fnv32_1a_accumulate(hash, key->offset_defs[i]->index);
+ hash = XXH32(&key->offset_defs[i]->index, sizeof(key->offset_defs[i]->index), hash);
- hash = _mesa_fnv32_1a_accumulate_block(
- hash, key->offset_defs_mul, key->offset_def_count * sizeof(uint64_t));
+ hash = XXH32(key->offset_defs_mul, key->offset_def_count * sizeof(uint64_t), hash);
return hash;
}
#include "nir_builder.h"
#include "util/u_dynarray.h"
-#define HASH(hash, data) _mesa_fnv32_1a_accumulate((hash), (data))
+#define HASH(hash, data) XXH32(&data, sizeof(data), hash)
static uint32_t
hash_src(uint32_t hash, const nir_src *src)
static uint32_t
hash_instr(const nir_instr *instr)
{
- uint32_t hash = _mesa_fnv32_1a_offset_bias;
+ uint32_t hash = 0;
switch (instr->type) {
case nir_instr_type_alu: