GPU: Better hash for specialization constants

Due to an error in the hash function the specialization constants hash
wasn't optimal. This PR fixes the hash function implementation by replacing
the addition with an xor.

Pull Request: https://projects.blender.org/blender/blender/pulls/120964
This commit is contained in:
Jeroen Bakker
2024-04-23 09:44:08 +02:00
parent 8a8921e7a8
commit 191b4fea5b

View File

@@ -1233,7 +1233,7 @@ struct DefaultHash<Vector<gpu::shader::ShaderCreateInfo::SpecializationConstant:
{
uint64_t hash = 0;
for (const gpu::shader::ShaderCreateInfo::SpecializationConstant::Value &value : key) {
hash = hash * 33 + value.u;
hash = hash * 33 ^ uint64_t(value.u);
}
return hash;
}