diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2019-10-01 13:33:39 +0300 |
---|---|---|
committer | Alexandre Julliard <julliard@winehq.org> | 2019-10-01 20:14:59 +0300 |
commit | 69660ca5c908fe17ab0ad717454fcd01fce93e0a (patch) | |
tree | 5d976b35ed34ba9c79e431f4d8b81e0e9ca4423d | |
parent | 1e5ebae3392a0b72c069280570a5cac7f00fd0a9 (diff) |
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>
-rw-r--r-- | include/private/vkd3d_common.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index ba4b68a5..d8fb3613 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[] = |