@@ -2700,7 +2700,7 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString(
27002700 #include <intrin.h> // For functions like __popcnt, _BitScanForward etc.
27012701#endif
27022702#if VMA_CPP20
2703- #include <bit> // For std::popcount
2703+ #include <bit>
27042704#endif
27052705
27062706#if VMA_STATS_STRING_ENABLED
@@ -3352,6 +3352,10 @@ static inline uint8_t VmaBitScanLSB(uint64_t mask)
33523352 if (_BitScanForward64(&pos, mask))
33533353 return static_cast<uint8_t>(pos);
33543354 return UINT8_MAX;
3355+ #elif VMA_CPP20
3356+ if(mask)
3357+ return static_cast<uint8_t>(std::countr_zero(mask));
3358+ return UINT8_MAX;
33553359#elif defined __GNUC__ || defined __clang__
33563360 return static_cast<uint8_t>(__builtin_ffsll(mask)) - 1U;
33573361#else
@@ -3374,6 +3378,10 @@ static inline uint8_t VmaBitScanLSB(uint32_t mask)
33743378 if (_BitScanForward(&pos, mask))
33753379 return static_cast<uint8_t>(pos);
33763380 return UINT8_MAX;
3381+ #elif VMA_CPP20
3382+ if(mask)
3383+ return static_cast<uint8_t>(std::countr_zero(mask));
3384+ return UINT8_MAX;
33773385#elif defined __GNUC__ || defined __clang__
33783386 return static_cast<uint8_t>(__builtin_ffs(mask)) - 1U;
33793387#else
@@ -3395,6 +3403,9 @@ static inline uint8_t VmaBitScanMSB(uint64_t mask)
33953403 unsigned long pos;
33963404 if (_BitScanReverse64(&pos, mask))
33973405 return static_cast<uint8_t>(pos);
3406+ #elif VMA_CPP20
3407+ if(mask)
3408+ return 63 - static_cast<uint8_t>(std::countl_zero(mask));
33983409#elif defined __GNUC__ || defined __clang__
33993410 if (mask)
34003411 return 63 - static_cast<uint8_t>(__builtin_clzll(mask));
@@ -3417,6 +3428,9 @@ static inline uint8_t VmaBitScanMSB(uint32_t mask)
34173428 unsigned long pos;
34183429 if (_BitScanReverse(&pos, mask))
34193430 return static_cast<uint8_t>(pos);
3431+ #elif VMA_CPP20
3432+ if(mask)
3433+ return 31 - static_cast<uint8_t>(std::countl_zero(mask));
34203434#elif defined __GNUC__ || defined __clang__
34213435 if (mask)
34223436 return 31 - static_cast<uint8_t>(__builtin_clz(mask));
0 commit comments