Mesa (master): i965/program_cache: Lift restriction on shader key size
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 12 12:29:58 UTC 2019
Module: Mesa
Branch: master
Commit: 3349b4b056cfe17cddfe2bc887fef48e8edab170
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3349b4b056cfe17cddfe2bc887fef48e8edab170
Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date: Fri Nov 8 17:47:57 2019 +0200
i965/program_cache: Lift restriction on shader key size
This will allow usage of packed structs which may have size
not divisible by 4.
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/mesa/drivers/dri/i965/brw_program_cache.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_program_cache.c b/src/mesa/drivers/dri/i965/brw_program_cache.c
index 88bb19792b0..e4b321bcc4c 100644
--- a/src/mesa/drivers/dri/i965/brw_program_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_program_cache.c
@@ -37,7 +37,7 @@
* data) in return. Objects in the cache may not have relocations
* (pointers to other BOs) in them.
*
- * The inner workings are a simple hash table based on a CRC of the
+ * The inner workings are a simple hash table based on a FNV-1a of the
* key data.
*
* Replacement is not implemented. Instead, when the cache gets too
@@ -96,17 +96,9 @@ brw_stage_cache_id(gl_shader_stage stage)
static GLuint
hash_key(struct brw_cache_item *item)
{
- GLuint *ikey = (GLuint *)item->key;
- GLuint hash = item->cache_id, i;
-
- assert(item->key_size % 4 == 0);
-
- /* I'm sure this can be improved on:
- */
- for (i = 0; i < item->key_size/4; i++) {
- hash ^= ikey[i];
- hash = (hash << 5) | (hash >> 27);
- }
+ uint32_t hash = _mesa_fnv32_1a_offset_bias;
+ hash = _mesa_fnv32_1a_accumulate(hash, item->cache_id);
+ hash = _mesa_fnv32_1a_accumulate_block(hash, item->key, item->key_size);
return hash;
}
More information about the mesa-commit
mailing list