From 2afe5344dfb7b19563046d7b2f522d91335aac66 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 18 Jan 2008 10:15:28 -0800 Subject: [965] Do a little bit rotation in state hash to reduce collisions. This was around 3% improvement in OA. --- src/mesa/drivers/dri/i965/brw_state_cache.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_state_cache.c') 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 && -- cgit v1.2.3