Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Tapani Pälli
On 08/18/2016 04:45 PM, Ilia Mirkin wrote: Since it *is* a hash, you could just use a much simpler hash function like int hash(int val) { int ret = val + 1000; if (ret == 0) ret = 1; return ret; } That way everything will map to a unique integer, except for -1000 which will map to the s

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Tapani Pälli
On 08/18/2016 09:08 PM, Eric Anholt wrote: Tapani Pälli writes: Implementation previously used case value itself as the key, however afterhash implementation change by ee02a5e we cannot use 0 as key. Patch uses _mesa_hash_data to formulate a suitable key for this hash. Signed-off-by: Tapani

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Eric Anholt
Tapani Pälli writes: > Implementation previously used case value itself as the key, however > afterhash implementation change by ee02a5e we cannot use 0 as key. > Patch uses _mesa_hash_data to formulate a suitable key for this hash. > > Signed-off-by: Tapani Pälli > Bugzilla: https://bugs.freede

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Ilia Mirkin
Since it *is* a hash, you could just use a much simpler hash function like int hash(int val) { int ret = val + 1000; if (ret == 0) ret = 1; return ret; } That way everything will map to a unique integer, except for -1000 which will map to the same thing as -999. I posit that this should be

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Ilia Mirkin
Can the hash value not be 0? On Aug 18, 2016 4:57 AM, "Tapani Pälli" wrote: > Implementation previously used case value itself as the key, however > afterhash implementation change by ee02a5e we cannot use 0 as key. > Patch uses _mesa_hash_data to formulate a suitable key for this hash. > > Sign

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Iago Toral
On Thu, 2016-08-18 at 14:25 +0300, Tapani Pälli wrote: > On 08/18/2016 01:08 PM, Iago Toral wrote: > > > > On Thu, 2016-08-18 at 11:57 +0300, Tapani Pälli wrote: > > > > > > Implementation previously used case value itself as the key, > > > however > > > afterhash implementation change by ee02a5e

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Tapani Pälli
On 08/18/2016 01:08 PM, Iago Toral wrote: On Thu, 2016-08-18 at 11:57 +0300, Tapani Pälli wrote: Implementation previously used case value itself as the key, however afterhash implementation change by ee02a5e we cannot use 0 as key. Patch uses _mesa_hash_data to formulate a suitable key for this

Re: [Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Iago Toral
On Thu, 2016-08-18 at 11:57 +0300, Tapani Pälli wrote: > Implementation previously used case value itself as the key, however > afterhash implementation change by ee02a5e we cannot use 0 as key. > Patch uses _mesa_hash_data to formulate a suitable key for this hash. > > Signed-off-by: Tapani Pälli

[Mesa-dev] [PATCH] glsl: fix key used for hashing switch statement cases

2016-08-18 Thread Tapani Pälli
Implementation previously used case value itself as the key, however afterhash implementation change by ee02a5e we cannot use 0 as key. Patch uses _mesa_hash_data to formulate a suitable key for this hash. Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97309 --