|
|
@@ -376,6 +376,13 @@ namespace bx
|
|
|
return Ty(_a) < Ty(1) ? Ty(0) : sizeof(Ty)*8 - countLeadingZeros<Ty>(_a - 1);
|
|
|
}
|
|
|
|
|
|
+ template<typename Ty>
|
|
|
+ inline BX_CONSTEXPR_FUNC uint8_t floorLog2(Ty _a)
|
|
|
+ {
|
|
|
+ BX_STATIC_ASSERT(isInteger<Ty>(), "Type Ty must be of integer type!");
|
|
|
+ return Ty(_a) < Ty(1) ? Ty(0) : sizeof(Ty)*8 - 1 - countLeadingZeros<Ty>(_a);
|
|
|
+ }
|
|
|
+
|
|
|
template<typename Ty>
|
|
|
inline BX_CONSTEXPR_FUNC Ty nextPow2(Ty _a)
|
|
|
{
|