[PATCH v2 02/12] vkd3d: Add MSVC path for vkd3d_log2i
Hans-Kristian Arntzen
post at arntzen-software.no
Tue Oct 1 05:33:39 CDT 2019
Signed-off-by: Hans-Kristian Arntzen <post at arntzen-software.no>
---
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[] =
--
2.23.0
More information about the wine-devel
mailing list