Merge branch '0.9.2' into gtx_ulp

master
Christophe Riccio ago%!(EXTRA string=14 years)
commit 79cec21c3a
  1. 2
      glm/core/func_matrix.inl
  2. 2
      glm/gtx/simd_vec4.inl
  3. 140
      test/core/core_func_matrix.cpp
  4. 11
      test/core/core_type_mat2x2.cpp
  5. 11
      test/core/core_type_mat2x3.cpp
  6. 12
      test/core/core_type_mat2x4.cpp
  7. 10
      test/core/core_type_mat3x2.cpp
  8. 17
      test/core/core_type_mat3x3.cpp
  9. 9
      test/core/core_type_mat3x4.cpp
  10. 11
      test/core/core_type_mat4x2.cpp
  11. 11
      test/core/core_type_mat4x3.cpp
  12. 15
      test/core/core_type_mat4x4.cpp
  13. 11
      test/core/core_type_vec1.cpp
  14. 15
      test/core/core_type_vec2.cpp
  15. 15
      test/core/core_type_vec3.cpp
  16. 23
      test/core/core_type_vec4.cpp
  17. 4
      test/gtc/gtc_quaternion.cpp
  18. 60
      test/gtc/gtc_swizzle.cpp
  19. 6
      test/gtx/gtx-bit.cpp
  20. 14
      test/gtx/gtx-simd-mat4.cpp

@ -466,8 +466,8 @@ namespace glm
detail::tmat2x2<T> Inverse( detail::tmat2x2<T> Inverse(
+ m[1][1] / Determinant, + m[1][1] / Determinant,
- m[1][0] / Determinant,
- m[0][1] / Determinant, - m[0][1] / Determinant,
- m[1][0] / Determinant,
+ m[0][0] / Determinant); + m[0][0] / Determinant);
return Inverse; return Inverse;

@ -275,7 +275,7 @@ namespace glm
detail::fvec4SIMD const & x detail::fvec4SIMD const & x
) )
{ {
GLM_ALIGN(4) detail::tvec4<float> Result; GLM_ALIGN(16) detail::tvec4<float> Result;
_mm_store_ps(&Result[0], x.Data); _mm_store_ps(&Result[0], x.Data);
return Result; return Result;
} }

@ -4,145 +4,79 @@
// Created : 2011-01-15 // Created : 2011-01-15
// Updated : 2011-01-15 // Updated : 2011-01-15
// Licence : This source is under MIT licence // Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp // File : test/core/func_matrix.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
#include <glm/glm.hpp> #include <glm/glm.hpp>
int test_static_assert() int test_matrixCompMult()
{ {
//glm::lessThan(glm::mat4(0), glm::mat4(4));
return 0;
}
int test_lessThan_vec2()
{
glm::bvec2 O = glm::bvec2(true, false);
glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2));
assert(glm::all(glm::equal(O, A)));
glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2));
assert(glm::all(glm::equal(O, B)));
glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2));
assert(glm::all(glm::equal(O, C)));
return 0;
}
int test_lessThan_vec3()
{
glm::bvec3 O = glm::bvec3(true, true, false);
glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
assert(glm::all(glm::equal(O, A)));
glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
assert(glm::all(glm::equal(O, B)));
glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
assert(glm::all(glm::equal(O, C)));
return 0;
}
int test_lessThan_vec4()
{
glm::bvec4 O = glm::bvec4(true, true, false, false);
glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, A)));
glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, B)));
glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, C)));
return 0; return 0;
} }
int test_greaterThanEqual_vec2() int test_outerProduct()
{ {
glm::bvec2 O = glm::bvec2(false, true);
glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2));
assert(glm::all(glm::equal(O, A)));
glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2));
assert(glm::all(glm::equal(O, B)));
glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2));
assert(glm::all(glm::equal(O, C)));
return 0; return 0;
} }
int test_greaterThanEqual_vec3() int test_transpose()
{ {
glm::bvec3 O = glm::bvec3(false, false, true);
glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
assert(glm::all(glm::equal(O, A)));
glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
assert(glm::all(glm::equal(O, B)));
glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
assert(glm::all(glm::equal(O, C)));
return 0; return 0;
} }
int test_greaterThanEqual_vec4() int test_determinant()
{ {
glm::bvec4 O = glm::bvec4(false, false, true, true);
glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, A)));
glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, B)));
glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
assert(glm::all(glm::equal(O, C)));
return 0; return 0;
} }
int test_all() int test_inverse()
{ {
assert(glm::all(glm::bvec2(true, true))); int Failed(0);
assert(!glm::all(glm::bvec2(true, false)));
assert(!glm::all(glm::bvec2(false, false))); glm::mat4x4 A4x4(
glm::vec4(1, 0, 1, 0),
assert(glm::all(glm::bvec3(true, true, true))); glm::vec4(0, 1, 0, 0),
assert(!glm::all(glm::bvec3(true, false, true))); glm::vec4(0, 0, 1, 0),
assert(!glm::all(glm::bvec3(false, false, false))); glm::vec4(0, 0, 0, 1));
glm::mat4x4 B4x4 = glm::inverse(A4x4);
glm::mat4x4 I4x4 = A4x4 * B4x4;
Failed += I4x4 == glm::mat4x4(1) ? 0 : 1;
glm::mat3x3 A3x3(
glm::vec3(1, 0, 1),
glm::vec3(0, 1, 0),
glm::vec3(0, 0, 1));
glm::mat3x3 B3x3 = glm::inverse(A3x3);
glm::mat3x3 I3x3 = A3x3 * B3x3;
Failed += I3x3 == glm::mat3x3(1) ? 0 : 1;
glm::mat2x2 A2x2(
glm::vec2(1, 1),
glm::vec2(0, 1));
glm::mat2x2 B2x2 = glm::inverse(A2x2);
glm::mat2x2 I2x2 = A2x2 * B2x2;
Failed += I2x2 == glm::mat2x2(1) ? 0 : 1;
assert(glm::all(glm::bvec4(true, true, true, true))); return Failed;
assert(!glm::all(glm::bvec4(true, false, true, false)));
assert(!glm::all(glm::bvec4(false, false, false, false)));
return 0;
} }
int main() int main()
{ {
int Failed = 0; int Failed = 0;
Failed += test_static_assert(); Failed += test_matrixCompMult();
Failed += test_lessThan_vec2(); Failed += test_outerProduct();
Failed += test_lessThan_vec3(); Failed += test_transpose();
Failed += test_lessThan_vec4(); Failed += test_determinant();
Failed += test_greaterThanEqual_vec2(); Failed += test_inverse();
Failed += test_greaterThanEqual_vec3();
Failed += test_greaterThanEqual_vec4();
Failed += test_all();
return Failed; return Failed;
} }

@ -9,7 +9,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::mat2x2 m(1.0f); glm::mat2x2 m(1.0f);
glm::vec2 u(1.0f); glm::vec2 u(1.0f);
@ -24,15 +24,14 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,7 +9,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::mat2x3 m(1.0f); glm::mat2x3 m(1.0f);
glm::vec2 u(1.0f); glm::vec2 u(1.0f);
@ -24,15 +24,14 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,7 +9,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::mat2x4 m(1.0f); glm::mat2x4 m(1.0f);
glm::vec2 u(1.0f); glm::vec2 u(1.0f);
@ -24,17 +24,17 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -24,16 +24,16 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -18,7 +18,7 @@ void print(glm::dmat3 const & Mat0)
printf("\tvec3(%2.3f, %2.3f, %2.3f))\n\n", Mat0[2][0], Mat0[2][1], Mat0[2][2]); printf("\tvec3(%2.3f, %2.3f, %2.3f))\n\n", Mat0[2][0], Mat0[2][1], Mat0[2][2]);
} }
bool test_mat3x3() int test_mat3x3()
{ {
glm::dmat3 Mat0( glm::dmat3 Mat0(
glm::dvec3(0.6f, 0.2f, 0.3f), glm::dvec3(0.6f, 0.2f, 0.3f),
@ -31,10 +31,10 @@ bool test_mat3x3()
print(Inv0); print(Inv0);
print(Res0); print(Res0);
return true; return 0;
} }
static bool test_operators() static int test_operators()
{ {
glm::mat3x3 m(1.0f); glm::mat3x3 m(1.0f);
glm::vec3 u(1.0f); glm::vec3 u(1.0f);
@ -49,17 +49,16 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_mat3x3(); Error += test_mat3x3();
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -24,16 +24,15 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,7 +9,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::mat4x2 m(1.0f); glm::mat4x2 m(1.0f);
glm::vec4 u(1.0f); glm::vec4 u(1.0f);
@ -24,16 +24,15 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,7 +9,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::mat4x3 m(1.0f); glm::mat4x3 m(1.0f);
glm::vec4 u(1.0f); glm::vec4 u(1.0f);
@ -24,17 +24,16 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -21,7 +21,7 @@ void print(glm::dmat4 const & Mat0)
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]); printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
} }
bool test_mat4x4() int test_mat4x4()
{ {
glm::dmat4 Mat0( glm::dmat4 Mat0(
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f), glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
@ -35,7 +35,7 @@ bool test_mat4x4()
print(Inv0); print(Inv0);
print(Res0); print(Res0);
return true; return 0;
} }
static bool test_operators() static bool test_operators()
@ -53,16 +53,15 @@ static bool test_operators()
bool R = m != q; bool R = m != q;
bool S = m == m; bool S = m == m;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_mat4x4(); Error += test_mat4x4();
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,22 +9,21 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::vec4 A(1.0f); glm::vec4 A(1.0f);
glm::vec4 B(1.0f); glm::vec4 B(1.0f);
bool R = A != B; bool R = A != B;
bool S = A == B; bool S = A == B;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,22 +9,21 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::vec4 A(1.0f); glm::vec2 A(1.0f);
glm::vec4 B(1.0f); glm::vec2 B(1.0f);
bool R = A != B; bool R = A != B;
bool S = A == B; bool S = A == B;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -9,22 +9,21 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
static bool test_operators() static int test_operators()
{ {
glm::vec4 A(1.0f); glm::vec3 A(1.0f);
glm::vec4 B(1.0f); glm::vec3 B(1.0f);
bool R = A != B; bool R = A != B;
bool S = A == B; bool S = A == B;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
bool Result = true; int Error = 0;
Result = Result && test_operators(); Error += test_operators();
assert(Result); return Error;
return Result;
} }

@ -31,41 +31,34 @@ enum comp
// return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value); // return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value);
//} //}
bool test_hvec4() int test_hvec4()
{ {
glm::hvec4 const A = glm::hvec4(0, 1, 2, 3); glm::hvec4 const A = glm::hvec4(0, 1, 2, 3);
//glm::hvec4 B = glm::swizzle<glm::X, glm::Y, glm::Z, glm::W>(A); //glm::hvec4 B = glm::swizzle<glm::X, glm::Y, glm::Z, glm::W>(A);
//glm::vec4 B = glm::detail::tvec##(glm::vec4::_size)<float>(); //glm::vec4 B = glm::detail::tvec##(glm::vec4::_size)<float>();
return true; return 0;
} }
static bool test_operators() static int test_operators()
{ {
glm::vec4 A(1.0f); glm::vec4 A(1.0f);
glm::vec4 B(1.0f); glm::vec4 B(1.0f);
bool R = A != B; bool R = A != B;
bool S = A == B; bool S = A == B;
return true; return (S && !R) ? 0 : 1;
} }
int main() int main()
{ {
test_hvec4();
//__m128 DataA = swizzle<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); //__m128 DataA = swizzle<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
//__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); //__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
bool Result = true; int Error = 0;
Error += test_operators();
Result = Result && test_operators(); Error += test_hvec4();
Result = Result && test_hvec4(); return Error;
assert(Result);
return Result;
return 0;
} }

@ -13,7 +13,7 @@
int main() int main()
{ {
int Failed = 0; int Error = -1;
return Failed; return Error;
} }

@ -13,114 +13,122 @@
int test_swizzle_vec4_ref_dynamic() int test_swizzle_vec4_ref_dynamic()
{ {
int Error = 0;
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B(2, 1, 0, 3); glm::ivec4 B(2, 1, 0, 3);
glm::swizzle(A, glm::Z, glm::Y, glm::X, glm::W) = B; glm::swizzle(A, glm::Z, glm::Y, glm::X, glm::W) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w); Error += (A.z == B.x && A.y == B.y && A.x == B.z && A.w == B.w) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec3 B(2, 1, 0); glm::ivec3 B(2, 1, 0);
glm::swizzle(A, glm::Z, glm::Y, glm::X) = B; glm::swizzle(A, glm::Z, glm::Y, glm::X) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z); Error += (A.z == B.x && A.y == B.y && A.x == B.z) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec2 B(2, 1); glm::ivec2 B(2, 1);
glm::swizzle(A, glm::Z, glm::Y) = B; glm::swizzle(A, glm::Z, glm::Y) = B;
assert(A.x == B.x && A.y == B.y); Error += (A.z == B.x && A.y == B.y) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
int B(2); int B(2);
glm::swizzle(A, glm::Z) = B; glm::swizzle(A, glm::Z) = B;
assert(A.x == B); Error += (A.z == B) ? 0 : 1;
} }
return 0; return Error;
} }
int test_swizzle_vec4_ref_static() int test_swizzle_vec4_ref_static()
{ {
int Error = 0;
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B(2, 1, 0, 3); glm::ivec4 B(2, 1, 0, 3);
glm::swizzle<glm::Z, glm::Y, glm::X, glm::W>(A) = B; glm::swizzle<glm::Z, glm::Y, glm::X, glm::W>(A) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w); Error += (A.z == B.x && A.y == B.y && A.x == B.z && A.w == B.w) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec3 B(2, 1, 0); glm::ivec3 B(2, 1, 0);
glm::swizzle<glm::Z, glm::Y, glm::X>(A) = B; glm::swizzle<glm::Z, glm::Y, glm::X>(A) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z); Error += (A.z == B.x && A.y == B.y && A.x == B.z) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec2 B(2, 1); glm::ivec2 B(2, 1);
glm::swizzle<glm::Z, glm::Y>(A) = B; glm::swizzle<glm::Z, glm::Y>(A) = B;
assert(A.x == B.x && A.y == B.y); Error += (A.z == B.x && A.y == B.y) ? 0 : 1;
} }
{ {
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
int B(2); int B(2);
glm::swizzle<glm::Z>(A) = B; glm::swizzle<glm::Z>(A) = B;
assert(A.x == B); Error += (A.z == B) ? 0 : 1;
} }
return 0; return Error;
} }
int test_swizzle_vec4_const_dynamic() int test_swizzle_vec4_const_dynamic()
{ {
int Error = 0;
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B = glm::swizzle(A, glm::B, glm::G, glm::R, glm::A); glm::ivec4 B = glm::swizzle(A, glm::B, glm::G, glm::R, glm::A);
assert(glm::all(glm::equal(A, B))); Error += (glm::all(glm::equal(glm::ivec4(2, 1, 0, 3), B))) ? 0 : 1;
glm::ivec3 C = glm::swizzle(A, glm::W, glm::Y, glm::Z); glm::ivec3 C = glm::swizzle(A, glm::W, glm::Y, glm::Z);
assert(glm::all(glm::equal(glm::ivec3(A), C))); Error += (glm::all(glm::equal(glm::ivec3(3, 1, 2), C))) ? 0 : 1;
glm::ivec2 D = glm::swizzle(A, glm::W, glm::X); glm::ivec2 D = glm::swizzle(A, glm::W, glm::X);
assert(glm::all(glm::equal(glm::ivec2(A), D))); Error += (glm::all(glm::equal(glm::ivec2(3, 0), D))) ? 0 : 1;
int E = glm::swizzle(A, glm::Q); int E = glm::swizzle(A, glm::Q);
assert(E == A.q); Error += (E == 3) ? 0 : 1;
return 0; return Error;
} }
int test_swizzle_vec4_const_static() int test_swizzle_vec4_const_static()
{ {
int Error = 0;
glm::ivec4 A(0, 1, 2, 3); glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B = glm::swizzle<glm::B, glm::G, glm::R, glm::A>(A); glm::ivec4 B = glm::swizzle<glm::B, glm::G, glm::R, glm::A>(A);
assert(glm::all(glm::equal(A, B))); Error += (glm::all(glm::equal(glm::ivec4(2, 1, 0, 3), B))) ? 0 : 1;
glm::ivec3 C = glm::swizzle<glm::W, glm::Y, glm::Z>(A); glm::ivec3 C = glm::swizzle<glm::W, glm::Y, glm::Z>(A);
assert(glm::all(glm::equal(glm::ivec3(A), C))); Error += (glm::all(glm::equal(glm::ivec3(3, 1, 2), C))) ? 0 : 1;
glm::ivec2 D = glm::swizzle<glm::W, glm::X>(A); glm::ivec2 D = glm::swizzle<glm::W, glm::X>(A);
assert(glm::all(glm::equal(glm::ivec2(A), D))); Error += (glm::all(glm::equal(glm::ivec2(3, 0), D))) ? 0 : 1;
int E = glm::swizzle<glm::Q>(A); int E = glm::swizzle<glm::Q>(A);
assert(E == A.q); Error += (E == 3) ? 0 : 1;
return 0; return Error;
} }
int main() int main()
{ {
int Failed = 0; int Error = 0;
Failed += test_swizzle_vec4_ref_dynamic(); Error += test_swizzle_vec4_ref_dynamic();
Failed += test_swizzle_vec4_ref_static(); Error += test_swizzle_vec4_ref_static();
Failed += test_swizzle_vec4_const_dynamic(); Error += test_swizzle_vec4_const_dynamic();
Failed += test_swizzle_vec4_const_static(); Error += test_swizzle_vec4_const_static();
return Failed; return Error;
} }

@ -129,6 +129,8 @@ namespace bitRevert
int main() int main()
{ {
::extractField::test(); bool Error = 0;
::bitRevert::test(); Error += ::extractField::test();
Error += ::bitRevert::test();
return Error;
} }

@ -224,14 +224,14 @@ int test_compute_gtx()
std::clock_t TimeEnd = clock(); std::clock_t TimeEnd = clock();
printf("test_compute_gtx: %ld\n", TimeEnd - TimeStart); printf("test_compute_gtx: %ld\n", TimeEnd - TimeStart);
return Output.size() != 0; return 0;
} }
int main() int main()
{ {
int Failed = GLM_COMPILER; int Error = 0;
std::vector<glm::mat4> Data(1024 * 1024 * 8); std::vector<glm::mat4> Data(64 * 64 * 1);
for(std::size_t i = 0; i < Data.size(); ++i) for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::mat4( Data[i] = glm::mat4(
glm::vec4(glm::compRand4(-2.0f, 2.0f)), glm::vec4(glm::compRand4(-2.0f, 2.0f)),
@ -277,13 +277,11 @@ int main()
glm::simdVec4 B(5.0f, 6.0f, 7.0f, 8.0f); glm::simdVec4 B(5.0f, 6.0f, 7.0f, 8.0f);
__m128 C = _mm_shuffle_ps(A.Data, B.Data, _MM_SHUFFLE(1, 0, 1, 0)); __m128 C = _mm_shuffle_ps(A.Data, B.Data, _MM_SHUFFLE(1, 0, 1, 0));
Failed += test_compute_glm(); Error += test_compute_glm();
Failed += test_compute_gtx(); Error += test_compute_gtx();
float Det = glm::determinant(glm::simdMat4(1.0)); float Det = glm::determinant(glm::simdMat4(1.0));
glm::simdMat4 D = glm::matrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0)); glm::simdMat4 D = glm::matrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0));
system("pause"); return Error;
return Failed;
} }

Loading…
Cancel
Save