From d4daef91509284d65d4acecbc53e89357444f80e Mon Sep 17 00:00:00 2001 From: Groove Date: Sun, 29 Jul 2018 22:30:19 +0200 Subject: [PATCH] Fixed invalid conversion from int scalar with vec4 constructor when using SSE instruction --- glm/detail/type_vec4_simd.inl | 6 +++--- readme.md | 1 + test/gtc/gtc_type_aligned.cpp | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/glm/detail/type_vec4_simd.inl b/glm/detail/type_vec4_simd.inl index 072e3915..519a5167 100644 --- a/glm/detail/type_vec4_simd.inl +++ b/glm/detail/type_vec4_simd.inl @@ -446,19 +446,19 @@ namespace detail template<> template<> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, float, aligned_lowp>::vec(int32 _x, int32 _y, int32 _z, int32 _w) : - data(_mm_castsi128_ps(_mm_set_epi32(_w, _z, _y, _x))) + data(_mm_cvtepi32_ps(_mm_set_epi32(_w, _z, _y, _x))) {} template<> template<> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, float, aligned_mediump>::vec(int32 _x, int32 _y, int32 _z, int32 _w) : - data(_mm_castsi128_ps(_mm_set_epi32(_w, _z, _y, _x))) + data(_mm_cvtepi32_ps(_mm_set_epi32(_w, _z, _y, _x))) {} template<> template<> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, float, aligned_highp>::vec(int32 _x, int32 _y, int32 _z, int32 _w) : - data(_mm_castsi128_ps(_mm_set_epi32(_w, _z, _y, _x))) + data(_mm_cvtepi32_ps(_mm_set_epi32(_w, _z, _y, _x))) {} #endif// GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE }//namespace glm diff --git a/readme.md b/readme.md index 7bdb7d09..20e3177a 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed Visual C++ 2013 warnings in vector relational code #782 - Fixed ICC build errors with constexpr #704 - Fixed defaulted operator= and constructors #791 +- Fixed invalid conversion from int scalar with vec4 constructor when using SSE instruction ### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22 #### Features: diff --git a/test/gtc/gtc_type_aligned.cpp b/test/gtc/gtc_type_aligned.cpp index 85517fc7..5c3741e7 100644 --- a/test/gtc/gtc_type_aligned.cpp +++ b/test/gtc/gtc_type_aligned.cpp @@ -127,19 +127,20 @@ static int test_ctor() return Error; } -using namespace glm; - -typedef mat<4, 4, float, aligned> aligned_mat4; - static int test_aligned_mat4() { int Error = 0; - aligned_mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); - aligned_mat4 t = transpose(m); - aligned_mat4 const expected = mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); - for (length_t l = 0; l < expected.length(); ++l) - Error += all(equal(t[l], expected[l], 0.0001f)) ? 0 : 1; + glm::aligned_vec4 const u(1.f, 2.f, 3.f, 4.f); + Error += glm::all(glm::equal(u, glm::aligned_vec4(1.f, 2.f, 3.f, 4.f), 0.0001f)) ? 0 : 1; + + glm::aligned_vec4 const v(1, 2, 3, 4); + Error += glm::all(glm::equal(v, glm::aligned_vec4(1.f, 2.f, 3.f, 4.f), 0.0001f)) ? 0 : 1; + + glm::aligned_mat4 const m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + glm::aligned_mat4 const t = glm::transpose(m); + glm::aligned_mat4 const expected = glm::mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + Error += glm::all(glm::equal(t, expected, 0.0001f)) ? 0 : 1; return Error; }