Module: vkd3d Branch: master Commit: 69660ca5c908fe17ab0ad717454fcd01fce93e0a URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=69660ca5c908fe17ab0ad717...
Author: Hans-Kristian Arntzen post@arntzen-software.no Date: Tue Oct 1 12:33:39 2019 +0200
vkd3d: Add MSVC path for vkd3d_log2i.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
include/private/vkd3d_common.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index ba4b68a..d8fb361 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -84,7 +84,13 @@ static inline bool vkd3d_bitmask_is_contiguous(unsigned int mask) /* Undefined for x == 0. */ static inline unsigned int vkd3d_log2i(unsigned int x) { -#ifdef HAVE_BUILTIN_CLZ +#ifdef _MSC_VER + /* _BitScanReverse returns the index of the highest set bit, + * unlike clz which is 31 - index. */ + unsigned long result; + _BitScanReverse(&result, x); + return (unsigned int)result; +#elif defined(HAVE_BUILTIN_CLZ) return __builtin_clz(x) ^ 0x1f; #else static const unsigned int l[] =