Commit cfbf769d by Tobin Ehlis Committed by Commit Bot

Vulkan:Level/Layer hash fix-up

Simplify has function for level/layer of imageView and add asserts to make sure that there won't be hash collisions. Bug: angleproject:4651 Change-Id: I8ab86a4f3d7aa668ad2c08e61bd5fd57744fcd12 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2257265Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 113c5e29
......@@ -883,9 +883,11 @@ struct hash<rx::vk::LayerLevel>
size_t operator()(const rx::vk::LayerLevel &layerLevel) const
{
// The left-shift by 11 was found to produce unique hash values
// in a 256x256 space for layer/level
return std::hash<uint32_t>()(layerLevel.layer) ^
(std::hash<uint32_t>()(layerLevel.level) << 11);
// in a [0..1000][0..2048] space for layer/level
// Make sure that layer/level hash bits don't overlap or overflow
ASSERT((layerLevel.layer & 0x000007FF) == layerLevel.layer);
ASSERT((layerLevel.level & 0xFFE00000) == 0);
return layerLevel.layer | (layerLevel.level << 11);
}
};
} // namespace std
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment