From: Eunki Hong Date: Wed, 20 Dec 2023 22:56:35 +0000 (+0900) Subject: Change VAO hash value function X-Git-Tag: dali_2.3.5~15^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=dd7d10717674a84325c3e1be19cd8889f9488f77 Change VAO hash value function Since std::hash{}(i); just return itself, we need to make some other method to calculate hash of location. For example, 0 location doesn't have any mean. and location with 1, 3 will collision as location 2. To avoid this hash collision, let we change some hash generate method. v = i + 1; hash += v << 24; v *= v; v ^= i; hash += v << 16; v *= v; hash += v; Note that if we skip v ^= i; operation, collision occured when location is near 13. Change-Id: Ie081d9a5e8895988ca7183dfc860176b69c4e337 Signed-off-by: Eunki Hong --- diff --git a/dali/internal/graphics/gles-impl/gles-context.cpp b/dali/internal/graphics/gles-impl/gles-context.cpp index e7379fb..dbdb318 100644 --- a/dali/internal/graphics/gles-impl/gles-context.cpp +++ b/dali/internal/graphics/gles-impl/gles-context.cpp @@ -60,7 +60,15 @@ struct Context::Impl std::size_t hash = 0; for(const auto& attr : vertexInputState.attributes) { - hash ^= std::hash{}(attr.location); + // Make unordered hash value by location. + // Note : This hash function varified for locations only under < 20. + std::size_t salt = attr.location + 1; + hash += salt << (sizeof(std::size_t) * 3 / 4); + salt *= salt; + salt ^= attr.location; + hash += salt << (sizeof(std::size_t) / 2); + salt *= salt; + hash += salt; } auto& gl = *mController.GetGL();