freedreno: replace fnv1a hash function with xxhash
[mesa.git] / src / gallium / drivers / freedreno / freedreno_batch_cache.c
index 9edca679449a36c04883d502029d854641a122da..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;
 }
 
@@ -377,6 +379,14 @@ batch_from_key(struct fd_batch_cache *cache, struct key *key,
        if (!batch)
                return NULL;
 
+       /* reset max_scissor, which will be adjusted on draws
+        * according to the actual scissor.
+        */
+       batch->max_scissor.minx = ~0;
+       batch->max_scissor.miny = ~0;
+       batch->max_scissor.maxx = 0;
+       batch->max_scissor.maxy = 0;
+
        fd_screen_lock(ctx->screen);
 
        _mesa_hash_table_insert_pre_hashed(cache->ht, hash, key, batch);