From 9e72e5ae67451e4b47a1313aefce249a15f67b07 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 7 Feb 2024 14:33:10 +0100 Subject: [PATCH] Fix and ignore warnings --- glm/detail/compute_vector_decl.hpp | 14 +- glm/detail/type_vec3.hpp | 1 + glm/detail/type_vec4.inl | 10 -- test/CMakeLists.txt | 125 ------------- test/core/core_force_compiler_unknown.cpp | 1 + test/gtc/gtc_type_aligned.cpp | 203 +++++++++++----------- 6 files changed, 106 insertions(+), 248 deletions(-) diff --git a/glm/detail/compute_vector_decl.hpp b/glm/detail/compute_vector_decl.hpp index a1b1043aa..00d7de5e1 100644 --- a/glm/detail/compute_vector_decl.hpp +++ b/glm/detail/compute_vector_decl.hpp @@ -99,7 +99,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a, vec const& b) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] &= static_cast(b[i]); return v; } @@ -111,7 +111,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a, vec const& b) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] |= static_cast(b[i]); return v; } @@ -123,7 +123,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a, vec const& b) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] ^= static_cast(b[i]); return v; } @@ -135,7 +135,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a, vec const& b) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] <<= static_cast(b[i]); return v; } @@ -147,7 +147,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a, vec const& b) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] >>= static_cast(b[i]); return v; } @@ -159,7 +159,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(vec const& v1, vec const& v2) { bool b = true; - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) b = b && detail::compute_equal::is_iec559>::call(v1.x, v2.x); return b; } @@ -180,7 +180,7 @@ namespace glm { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& a) { vec v(a); - for (int i = 0; i < L; ++i) + for (length_t i = 0; i < L; ++i) v[i] = ~v[i]; return v; } diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 8b221205f..931210ac4 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -37,6 +37,7 @@ namespace glm # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wgnu-anonymous-struct" # pragma clang diagnostic ignored "-Wnested-anon-types" +# pragma clang diagnostic ignored "-Wpadded" # elif GLM_COMPILER & GLM_COMPILER_VC # pragma warning(push) # pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index c147ca094..79a51b6f3 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -361,13 +361,8 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) { -<<<<<<< HEAD GLM_ASSERT_LENGTH(i, this->length()); switch(i) -======= - assert(i >= 0 && i < this->length()); - switch (i) ->>>>>>> 5c1da05b (Simd improvement) { default: case 0: @@ -384,13 +379,8 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) const { -<<<<<<< HEAD GLM_ASSERT_LENGTH(i, this->length()); switch(i) -======= - assert(i >= 0 && i < this->length()); - switch (i) ->>>>>>> 5c1da05b (Simd improvement) { default: case 0: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f0153a0fa..7b618ede3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,122 +2,6 @@ option(GLM_QUIET "No CMake Message" OFF) option(GLM_TEST_ENABLE "Build unit tests" ON) option(GLM_PERF_TEST_ENABLE "Build perf tests" OFF) -<<<<<<< HEAD -======= -option(GLM_TEST_ENABLE_SIMD_SSE2 "Enable SSE2 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_SSE3 "Enable SSE3 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_SSSE3 "Enable SSSE3 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_SSE4_1 "Enable SSE 4.1 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_SSE4_2 "Enable SSE 4.2 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_AVX "Enable AVX optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_AVX2 "Enable AVX2 optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_NEON "Enable ARM NEON optimizations" OFF) -option(GLM_TEST_ENABLE_SIMD_FMA "Enable FMA optimizations" OFF) -option(GLM_TEST_FORCE_PURE "Force 'pure' instructions" OFF) - -if(GLM_TEST_FORCE_PURE) - add_definitions(-DGLM_FORCE_PURE) - - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - add_compile_options(-mfpmath=387) - endif() - message(STATUS "GLM: No SIMD instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_AVX2) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-mavx2) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxAVX2) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/arch:AVX2) - endif() - message(STATUS "GLM: AVX2 instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_AVX) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-mavx) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxAVX) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/arch:AVX) - endif() - message(STATUS "GLM: AVX instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_SSE4_2) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-msse4.2) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxSSE4.2) - elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64) - add_compile_options(/arch:SSE2) # VC doesn't support SSE4.2 - endif() - message(STATUS "GLM: SSE4.2 instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_SSE4_1) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-msse4.1) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxSSE4.1) - elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64) - add_compile_options(/arch:SSE2) # VC doesn't support SSE4.1 - endif() - message(STATUS "GLM: SSE4.1 instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_SSSE3) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-mssse3) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxSSSE3) - elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64) - add_compile_options(/arch:SSE2) # VC doesn't support SSSE3 - endif() - message(STATUS "GLM: SSSE3 instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_SSE3) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-msse3) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxSSE3) - elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64) - add_compile_options(/arch:SSE2) # VC doesn't support SSE3 - endif() - message(STATUS "GLM: SSE3 instruction set") - -elseif(GLM_TEST_ENABLE_SIMD_SSE2) - add_definitions(-DGLM_FORCE_INTRINSICS) - - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-msse2) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_options(/QxSSE2) - elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64) - add_compile_options(/arch:SSE2) - endif() - message(STATUS "GLM: SSE2 instruction set") -elseif(GLM_TEST_ENABLE_SIMD_NEON) - add_definitions(-DGLM_FORCE_NEON) - message(STATUS "GLM: ARM NEON instruction set") -endif() - -if (GLM_TEST_ENABLE_SIMD_FMA) - add_definitions(-DGLM_FORCE_FMA) - if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-mfma) - endif() -endif() ->>>>>>> 5c1da05b (Simd improvement) # Compiler and default options @@ -130,15 +14,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(NOT GLM_DISABLE_AUTO_DETECTION) add_compile_options(-Werror -Weverything) endif() -<<<<<<< HEAD -======= - if (NOT APPLE) - add_compile_options(-Wno-unsafe-buffer-usage) #this option makes MacOS compilation fail but prevent error on windows - endif() - - add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-gnu-anonymous-struct -Wno-nested-anon-types) - add_compile_options(-Wno-undefined-reinterpret-cast -Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare -Wno-global-constructors -Wno-unused-macros -Wno-format-nonliteral -Wno-float-equal) ->>>>>>> 5c1da05b (Simd improvement) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(NOT GLM_QUIET) diff --git a/test/core/core_force_compiler_unknown.cpp b/test/core/core_force_compiler_unknown.cpp index 33284d09b..85c96b266 100644 --- a/test/core/core_force_compiler_unknown.cpp +++ b/test/core/core_force_compiler_unknown.cpp @@ -15,6 +15,7 @@ #elif defined(_MSC_VER) # pragma warning(push) # pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union +# pragma warning(disable: 4324) // structure was padded due to alignment specifier #endif #include diff --git a/test/gtc/gtc_type_aligned.cpp b/test/gtc/gtc_type_aligned.cpp index 7074c665a..610fe3b4f 100644 --- a/test/gtc/gtc_type_aligned.cpp +++ b/test/gtc/gtc_type_aligned.cpp @@ -3,6 +3,7 @@ #if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE #include #include +#include #include #include @@ -97,35 +98,35 @@ static int test_copy_vec4() { glm::aligned_vec4 const u(1.f, 2.f, 3.f, 4.f); glm::packed_vec4 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.w ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.w, glm::epsilon()) ? 0 : 1; } { glm::packed_vec4 const u(1.f, 2.f, 3.f, 4.f); glm::aligned_vec4 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.w ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.w, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec4 const u(1., 2., 3., 4.); glm::packed_dvec4 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.w ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.w, glm::epsilon()) ? 0 : 1; } { glm::packed_dvec4 const u(1.f, 2.f, 3.f, 4.f); glm::aligned_dvec4 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.w ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.w, glm::epsilon()) ? 0 : 1; } { @@ -154,31 +155,31 @@ static int test_copy_vec3() { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::packed_vec3 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { glm::packed_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec3 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::packed_dvec3 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { glm::packed_dvec3 const u(1.f, 2.f, 3.f); glm::aligned_dvec3 const v(u); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { @@ -205,49 +206,49 @@ static int test_splat_vec3() { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec3 const v(glm::splatX(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.x ? 0 : 1; - Error += v.z == u.x ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.x, glm::epsilon()) ? 0 : 1; } { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec3 const v(glm::splatY(u)); - Error += v.x == u.y ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.y ? 0 : 1; + Error += glm::equal(v.x, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.y, glm::epsilon()) ? 0 : 1; } { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec3 const v(glm::splatZ(u)); - Error += v.x == u.z ? 0 : 1; - Error += v.y == u.z ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec3 const v(glm::splatX(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.x ? 0 : 1; - Error += v.z == u.x ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.x, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec3 const v(glm::splatY(u)); - Error += v.x == u.y ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.y ? 0 : 1; + Error += glm::equal(v.x, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.y, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec3 const v(glm::splatZ(u)); - Error += v.x == u.z ? 0 : 1; - Error += v.y == u.z ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } return Error; @@ -260,52 +261,52 @@ static int test_splat_vec4() glm::aligned_vec4 const u(1.f, 2.f, 3.f, 4.f); { glm::aligned_vec4 const v(glm::splatX(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.x ? 0 : 1; - Error += v.z == u.x ? 0 : 1; - Error += v.w == u.x ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.x, glm::epsilon()) ? 0 : 1; } { glm::aligned_vec4 const v(glm::splatY(u)); - Error += v.x == u.y ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.y ? 0 : 1; - Error += v.w == u.y ? 0 : 1; + Error += glm::equal(v.x, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.y, glm::epsilon()) ? 0 : 1; } { glm::aligned_vec4 const v(glm::splatZ(u)); - Error += v.x == u.z ? 0 : 1; - Error += v.y == u.z ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.z ? 0 : 1; + Error += glm::equal(v.x, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.z, glm::epsilon()) ? 0 : 1; } } { glm::aligned_dvec4 const u(1.f, 2.f, 3.f, 4.f); { glm::aligned_dvec4 const v(glm::splatX(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.x ? 0 : 1; - Error += v.z == u.x ? 0 : 1; - Error += v.w == u.x ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.x, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec4 const v(glm::splatY(u)); - Error += v.x == u.y ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.y ? 0 : 1; - Error += v.w == u.y ? 0 : 1; + Error += glm::equal(v.x, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.y, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec4 const v(glm::splatZ(u)); - Error += v.x == u.z ? 0 : 1; - Error += v.y == u.z ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.z ? 0 : 1; + Error += glm::equal(v.x, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.z, glm::epsilon()) ? 0 : 1; } } return Error; @@ -318,72 +319,62 @@ static int test_copy_vec4_vec3() { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec4 const v(glm::xyz0(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == 0.0f ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, 0.0f, glm::epsilon()) ? 0 : 1; } { glm::aligned_vec3 const u(1.f, 2.f, 3.f); glm::aligned_vec4 const v(glm::xyz1(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == 1.0f ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, 1.0f, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec4 const v(glm::xyz0(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == 0. ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, 0.0, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec4 const v(glm::xyz1(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == 1.0 ? 0 : 1; - } - - { - glm::aligned_dvec3 const u(1., 2., 3.); - glm::aligned_dvec4 const v(glm::xyzz(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, 1.0, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec3 const u(1., 2., 3.); glm::aligned_dvec4 const v(glm::xyzz(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; - Error += v.w == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.w, u.z, glm::epsilon()) ? 0 : 1; } - { glm::aligned_vec4 const u(1.f, 2.f, 3.f, 4.f); glm::aligned_vec3 const v(glm::xyz(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } { glm::aligned_dvec4 const u(1., 2., 3., 4.); glm::aligned_dvec3 const v(glm::xyz(u)); - Error += v.x == u.x ? 0 : 1; - Error += v.y == u.y ? 0 : 1; - Error += v.z == u.z ? 0 : 1; + Error += glm::equal(v.x, u.x, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.y, u.y, glm::epsilon()) ? 0 : 1; + Error += glm::equal(v.z, u.z, glm::epsilon()) ? 0 : 1; } return Error; }