Fixed vec4 SIMD constexpr #653

This commit is contained in:
Christophe Riccio
2017-07-26 02:06:33 +02:00
parent aa026cc0da
commit 950d226154
11 changed files with 64 additions and 73 deletions

View File

@@ -61,7 +61,7 @@ int test_ctr()
#if GLM_HAS_INITIALIZER_LISTS
glm::mat2x2 m0(
glm::vec2(0, 1),
glm::vec2(0, 1),
glm::vec2(2, 3));
glm::mat2x2 m1{0, 1, 2, 3};

View File

@@ -38,6 +38,10 @@ int test_vec1_ctor()
{
int Error = 0;
# if GLM_HAS_CONSTEXPR
constexpr glm::vec1 v(0);
# endif
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec1>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec1>::value ? 0 : 1;

View File

@@ -199,6 +199,10 @@ int test_vec2_ctor()
{
int Error = 0;
# if GLM_HAS_CONSTEXPR
constexpr glm::vec2 v(0);
# endif
{
glm::vec2 A(1);
glm::vec2 B(A);

View File

@@ -15,6 +15,10 @@ int test_vec3_ctor()
{
int Error = 0;
# if GLM_HAS_CONSTEXPR
constexpr glm::vec3 v(0);
# endif
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec3>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec3>::value ? 0 : 1;
@@ -259,7 +263,7 @@ int test_vec3_swizzle3_2()
int Error = 0;
glm::vec3 v(1, 2, 3);
glm::vec2 u;
glm::vec2 u(0);
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
// Can not assign a vec3 swizzle to a vec2
@@ -322,7 +326,7 @@ int test_vec3_swizzle3_3()
int Error = 0;
glm::vec3 v(1, 2, 3);
glm::vec3 u;
glm::vec3 u(0);
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
@@ -348,7 +352,7 @@ int test_vec3_swizzle_operators()
{
int Error = 0;
glm::vec3 q, u, v;
glm::vec3 q(0), u, v;
u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30);
@@ -405,9 +409,9 @@ int test_vec3_swizzle_functions()
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.yy())); Error += (int(r) == 60) ? 0 : 1;
// vec3
glm::vec3 q, u, v;
u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30);
glm::vec3 q(0);
glm::vec3 u = glm::vec3(1, 2, 3);
glm::vec3 v = glm::vec3(10, 20, 30);
r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1;
r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1;
r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1;
@@ -415,9 +419,8 @@ int test_vec3_swizzle_functions()
r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1;
// vec4
glm::vec4 s, t;
s = glm::vec4(1, 2, 3, 4);
t = glm::vec4(10, 20, 30, 40);
glm::vec4 s = glm::vec4(1, 2, 3, 4);
glm::vec4 t = glm::vec4(10, 20, 30, 40);
r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
@@ -483,9 +486,6 @@ int main()
{
int Error = 0;
glm::vec3 v;
assert(v.length() == 3);
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();

View File

@@ -37,6 +37,10 @@ int test_vec4_ctor()
{
int Error = 0;
# if GLM_HAS_CONSTEXPR
constexpr glm::vec4 v(0.0f);
# endif
{
glm::ivec4 A(1, 2, 3, 4);
glm::ivec4 B(A);
@@ -546,8 +550,6 @@ int main()
printf("GNI\n");
}
*/
glm::vec4 v;
assert(v.length() == 4);
# ifdef NDEBUG
std::size_t const Size(1000000);