summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-01-18 10:15:28 -0800
committerEric Anholt <eric@anholt.net>2008-01-18 10:15:28 -0800
commit2afe5344dfb7b19563046d7b2f522d91335aac66 (patch)
treec8a3accef3d0114183e41044c9d75e4754e7a42b /src/mesa/drivers
parent8c56418f979f4b8c79c80738b35ac03470c25fea (diff)
[965] Do a little bit rotation in state hash to reduce collisions.
This was around 3% improvement in OA.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_cache.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c
index 315fd9f206..9e5e623561 100644
--- a/src/mesa/drivers/dri/i965/brw_state_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_state_cache.c
@@ -79,14 +79,18 @@ static GLuint hash_key( const void *key, GLuint key_size,
/* I'm sure this can be improved on:
*/
- for (i = 0; i < key_size/4; i++)
+ for (i = 0; i < key_size/4; i++) {
hash ^= ikey[i];
+ hash = (hash << 5) | (hash >> 27);
+ }
/* Include the BO pointers as key data as well */
ikey = (void *)reloc_bufs;
key_size = nr_reloc_bufs * sizeof(dri_bo *);
- for (i = 0; i < key_size/4; i++)
+ for (i = 0; i < key_size/4; i++) {
hash ^= ikey[i];
+ hash = (hash << 5) | (hash >> 27);
+ }
return hash;
}
@@ -111,6 +115,16 @@ search_cache(struct brw_cache *cache, enum brw_cache_id cache_id,
{
struct brw_cache_item *c;
+#if 0
+ int bucketcount = 0;
+
+ for (c = cache->items[hash % cache->size]; c; c = c->next)
+ bucketcount++;
+
+ fprintf(stderr, "bucket %d/%d = %d/%d items\n", hash % cache->size,
+ cache->size, bucketcount, cache->n_items);
+#endif
+
for (c = cache->items[hash % cache->size]; c; c = c->next) {
if (c->cache_id == cache_id &&
c->hash == hash &&