Optimized sign for vector types #271

This commit is contained in:
Christophe Riccio
2014-11-21 00:50:47 +01:00
parent 883d328fb8
commit b0b84a3dc1
2 changed files with 39 additions and 4 deletions

View File

@@ -855,6 +855,12 @@ namespace sign
int Error = 0;
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = glm::sign(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = sign_cmp(Data[i].Value);
@@ -888,11 +894,36 @@ namespace sign
return Error;
}
int test_i32vec4()
{
type<glm::i32vec4> const Data[] =
{
{glm::i32vec4( 1), glm::i32vec4( 1)},
{glm::i32vec4( 0), glm::i32vec4( 0)},
{glm::i32vec4( 2), glm::i32vec4( 1)},
{glm::i32vec4( 3), glm::i32vec4( 1)},
{glm::i32vec4(-1), glm::i32vec4(-1)},
{glm::i32vec4(-2), glm::i32vec4(-1)},
{glm::i32vec4(-3), glm::i32vec4(-1)}
};
int Error = 0;
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::i32vec4>); ++i)
{
glm::i32vec4 Result = glm::sign(Data[i].Value);
Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1;
}
return Error;
}
int test()
{
int Error = 0;
Error += test_int32();
Error += test_i32vec4();
return Error;
}