Fixed mod function specialization #281 Fixed bitscan detection

This commit is contained in:
Christophe Riccio
2014-11-29 18:47:58 +01:00
parent 9b250cc86f
commit 7e81213fdd
8 changed files with 225 additions and 36 deletions

View File

@@ -30,6 +30,7 @@
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_INLINE
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/integer.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/vec1.hpp>
@@ -102,7 +103,7 @@ namespace log2_
printf("glm::log2<ivec4>: %d clocks\n", End - Begin);
}
# if(GLM_ARCH != GLM_ARCH_PURE) && (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
# if GLM_HAS_BITSCAN_WINDOWS
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
@@ -163,7 +164,7 @@ namespace log2_
printf("glm::log2<ivec4> reinterpret: %d clocks\n", End - Begin);
}
# endif//GLM_ARCH != GLM_ARCH_PURE
# endif//GLM_HAS_BITSCAN_WINDOWS
{
std::vector<float> Result;
@@ -197,12 +198,70 @@ namespace log2_
}
}//namespace log2_
namespace mod_
{
int test()
{
int Error(0);
{
float A(3.0);
float B(2.0f);
float C = glm::mod(A, B);
Error += glm::abs(C - 1.0f) < 0.00001f ? 0 : 1;
}
{
glm::vec4 A(3.0);
float B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
{
glm::vec4 A(3.0);
glm::vec4 B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
{
int A(3);
int B(2);
int C = glm::mod(A, B);
Error += C == 1 ? 0 : 1;
}
{
glm::ivec4 A(3);
int B(2);
glm::ivec4 C = glm::mod(A, B);
Error += glm::all(glm::equal(C, glm::ivec4(1))) ? 0 : 1;
}
{
glm::ivec4 A(3);
glm::ivec4 B(2);
glm::ivec4 C = glm::mod(A, B);
Error += glm::all(glm::equal(C, glm::ivec4(1))) ? 0 : 1;
}
return Error;
}
}//namespace mod_
int main()
{
int Error(0);
Error += ::log2_::test();
Error += ::mod_::test();
# ifdef GLM_TEST_ENABLE_PERF
Error += ::log2_::perf();