diff options
author | Robert Bragg <robert@linux.intel.com> | 2010-11-04 13:57:36 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2010-12-07 16:00:32 +0000 |
commit | 046434e222cff3717a0a2c46cdfb6b399621511a (patch) | |
tree | cd4712f85aa5fef0894bfaf582d63763306dd1d2 /cogl/cogl-util.h | |
parent | 2c9cd76baa76aa6ad4b6612bece7585ba9ed95b2 (diff) | |
download | cogl-046434e222cff3717a0a2c46cdfb6b399621511a.tar.gz |
pipeline: Implements _cogl_pipeline_hash function
This allows us to get a hash for a set of state groups for a given
pipeline. This can be used for example to get a hash of the fragment
processing state of a pipeline so we can implement a cache for compiled
arbfp/glsl programs.
Diffstat (limited to 'cogl/cogl-util.h')
-rw-r--r-- | cogl/cogl-util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h index 64ba8ffc..0ac56c9d 100644 --- a/cogl/cogl-util.h +++ b/cogl/cogl-util.h @@ -68,4 +68,31 @@ _cogl_util_is_pot (unsigned int num) return (num & (num - 1)) == 0; } +/* Split Bob Jenkins' One-at-a-Time hash + * + * This uses the One-at-a-Time hash algorithm designed by Bob Jenkins + * but the mixing step is split out so the function can be used in a + * more incremental fashion. + */ +static inline unsigned int +_cogl_util_one_at_a_time_hash (unsigned int hash, + void *key, + size_t bytes) +{ + unsigned char *p = key; + int i; + + for (i = 0; i < bytes; i++) + { + hash += p[i]; + hash += (hash << 10); + hash ^= (hash >> 6); + } + + return hash; +} + +unsigned int +_cogl_util_one_at_a_time_mix (unsigned int hash); + #endif /* __COGL_UTIL_H */ |