This commit is contained in:
Christophe 2024-01-17 16:04:42 +01:00
parent 4e943545ee
commit bbfa2ff863

View file

@ -10,6 +10,11 @@
namespace isPowerOfTwo
{
#if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
#endif
template<typename genType>
struct type
{
@ -17,7 +22,11 @@ namespace isPowerOfTwo
bool Return;
};
int test_int16()
#if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
#endif
static int test_int16()
{
type<glm::int16> const Data[] =
{
@ -40,7 +49,7 @@ namespace isPowerOfTwo
return Error;
}
int test_uint16()
static int test_uint16()
{
type<glm::uint16> const Data[] =
{
@ -63,7 +72,7 @@ namespace isPowerOfTwo
return Error;
}
int test_int32()
static int test_int32()
{
type<int> const Data[] =
{
@ -86,7 +95,7 @@ namespace isPowerOfTwo
return Error;
}
int test_uint32()
static int test_uint32()
{
type<glm::uint> const Data[] =
{
@ -109,7 +118,7 @@ namespace isPowerOfTwo
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -125,7 +134,8 @@ namespace isPowerOfTwo
namespace nextPowerOfTwo_advanced
{
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
GLM_FUNC_QUALIFIER
static genIUType highestBitValue(genIUType Value)
{
genIUType tmp = Value;
genIUType result = genIUType(0);
@ -138,7 +148,8 @@ namespace nextPowerOfTwo_advanced
}
template<typename genType>
GLM_FUNC_QUALIFIER genType nextPowerOfTwo_loop(genType value)
GLM_FUNC_QUALIFIER
static genType nextPowerOfTwo_loop(genType value)
{
return glm::isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
@ -150,7 +161,7 @@ namespace nextPowerOfTwo_advanced
genType Return;
};
int test_int32()
static int test_int32()
{
type<glm::int32> const Data[] =
{
@ -179,7 +190,7 @@ namespace nextPowerOfTwo_advanced
return Error;
}
int test_uint32()
static int test_uint32()
{
type<glm::uint32> const Data[] =
{
@ -206,7 +217,7 @@ namespace nextPowerOfTwo_advanced
return Error;
}
int perf()
static int perf()
{
int Error(0);
@ -231,7 +242,7 @@ namespace nextPowerOfTwo_advanced
return Error;
}
int test()
static int test()
{
int Error(0);
@ -245,7 +256,7 @@ namespace nextPowerOfTwo_advanced
namespace prevPowerOfTwo
{
template <typename T>
int run()
static int run()
{
int Error = 0;
@ -264,7 +275,7 @@ namespace prevPowerOfTwo
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -285,7 +296,7 @@ namespace prevPowerOfTwo
namespace nextPowerOfTwo
{
template <typename T>
int run()
static int run()
{
int Error = 0;
@ -304,7 +315,7 @@ namespace nextPowerOfTwo
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -333,7 +344,7 @@ namespace prevMultiple
};
template <typename T>
int run()
static int run()
{
type<T> const Data[] =
{
@ -352,7 +363,7 @@ namespace prevMultiple
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -374,7 +385,7 @@ namespace nextMultiple
{
static glm::uint const Multiples = 128;
int perf_nextMultiple(glm::uint Samples)
static int perf_nextMultiple(glm::uint Samples)
{
std::vector<glm::uint> Results(Samples * Multiples);
@ -398,13 +409,14 @@ namespace nextMultiple
}
template <typename T>
GLM_FUNC_QUALIFIER T nextMultipleMod(T Source, T Multiple)
GLM_FUNC_QUALIFIER
static T nextMultipleMod(T Source, T Multiple)
{
T const Tmp = Source - static_cast<T>(1);
return Tmp + (Multiple - (Tmp % Multiple));
}
int perf_nextMultipleMod(glm::uint Samples)
static int perf_nextMultipleMod(glm::uint Samples)
{
std::vector<glm::uint> Results(Samples * Multiples);
@ -432,7 +444,8 @@ namespace nextMultiple
# pragma warning(disable : 4146)
#endif
template <typename T>
GLM_FUNC_QUALIFIER T nextMultipleNeg(T Source, T Multiple)
GLM_FUNC_QUALIFIER
static T nextMultipleNeg(T Source, T Multiple)
{
if(Source > static_cast<T>(0))
{
@ -446,7 +459,7 @@ namespace nextMultiple
# pragma warning(pop)
#endif
int perf_nextMultipleNeg(glm::uint Samples)
static int perf_nextMultipleNeg(glm::uint Samples)
{
std::vector<glm::uint> Results(Samples * Multiples);
@ -470,12 +483,13 @@ namespace nextMultiple
}
template <typename T>
GLM_FUNC_QUALIFIER T nextMultipleUFloat(T Source, T Multiple)
GLM_FUNC_QUALIFIER
static T nextMultipleUFloat(T Source, T Multiple)
{
return Source + (Multiple - std::fmod(Source, Multiple));
}
int perf_nextMultipleUFloat(glm::uint Samples)
static int perf_nextMultipleUFloat(glm::uint Samples)
{
std::vector<float> Results(Samples * Multiples);
@ -499,7 +513,8 @@ namespace nextMultiple
}
template <typename T>
GLM_FUNC_QUALIFIER T nextMultipleFloat(T Source, T Multiple)
GLM_FUNC_QUALIFIER
static T nextMultipleFloat(T Source, T Multiple)
{
if(Source > static_cast<float>(0))
return Source + (Multiple - std::fmod(Source, Multiple));
@ -507,7 +522,7 @@ namespace nextMultiple
return Source + std::fmod(-Source, Multiple);
}
int perf_nextMultipleFloat(glm::uint Samples)
static int perf_nextMultipleFloat(glm::uint Samples)
{
std::vector<float> Results(Samples * Multiples);
@ -539,7 +554,7 @@ namespace nextMultiple
};
template <typename T>
int test_uint()
static int test_uint()
{
type<T> const Data[] =
{
@ -567,7 +582,7 @@ namespace nextMultiple
return Error;
}
int perf()
static int perf()
{
int Error = 0;
@ -587,7 +602,7 @@ namespace nextMultiple
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -616,7 +631,7 @@ namespace findNSB
};
template <typename T>
int run()
static int run()
{
type<T> const Data[] =
{
@ -644,7 +659,7 @@ namespace findNSB
return Error;
}
int test()
static int test()
{
int Error = 0;
@ -675,10 +690,8 @@ int main()
Error += prevMultiple::test();
Error += nextMultiple::test();
# ifdef NDEBUG
Error += nextPowerOfTwo_advanced::perf();
Error += nextMultiple::perf();
# endif//NDEBUG
Error += nextPowerOfTwo_advanced::perf();
Error += nextMultiple::perf();
return Error;
}