diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index a6dbb3f7..9232cdc6 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -4,6 +4,24 @@ namespace glm{ namespace detail { + template + struct is_int32 + { + enum test {value = 0}; + }; + + template <> + struct is_int32 + { + enum test {value = ~0}; + }; + + template <> + struct is_int32 + { + enum test {value = ~0}; + }; + template struct compute_vec4_add { @@ -67,7 +85,7 @@ namespace detail } }; - template + template struct compute_vec4_xor { static tvec4 call(tvec4 const & a, tvec4 const & b) @@ -76,7 +94,7 @@ namespace detail } }; - template + template struct compute_vec4_shift_left { static tvec4 call(tvec4 const & a, tvec4 const & b) @@ -85,7 +103,7 @@ namespace detail } }; - template + template struct compute_vec4_shift_right { static tvec4 call(tvec4 const & a, tvec4 const & b) @@ -93,6 +111,15 @@ namespace detail return tvec4(a.x >> b.x, a.y >> b.y, a.z >> b.z, a.w >> b.w); } }; + + template + struct compute_vec4_logical_not + { + static tvec4 call(tvec4 const & v) + { + return tvec4(~v.x, ~v.y, ~v.z, ~v.w); + } + }; }//namespace detail // -- Implicit basic constructors -- @@ -883,7 +910,7 @@ namespace detail template GLM_FUNC_QUALIFIER tvec4 operator~(tvec4 const & v) { - return tvec4(~v.x, ~v.y, ~v.z, ~v.w); + return detail::compute_vec4_logical_not::value>::call(v); } // -- Boolean operators -- diff --git a/glm/detail/type_vec4_simd.inl b/glm/detail/type_vec4_simd.inl index 9c46ac5c..c82062a6 100644 --- a/glm/detail/type_vec4_simd.inl +++ b/glm/detail/type_vec4_simd.inl @@ -105,68 +105,46 @@ namespace detail } }; - template - struct compute_vec4_xor + template + struct compute_vec4_xor { - static tvec4 call(tvec4 const& a, tvec4 const& b) + static tvec4 call(tvec4 const& a, tvec4 const& b) { - tvec4 Result(uninitialize); + tvec4 Result(uninitialize); Result.data = _mm_xor_si128(a.data, b.data); return Result; } }; - template - struct compute_vec4_xor + template + struct compute_vec4_shift_left { - static tvec4 call(tvec4 const& a, tvec4 const& b) + static tvec4 call(tvec4 const& a, tvec4 const& b) { - tvec4 Result(uninitialize); - Result.data = _mm_xor_si128(a.data, b.data); - return Result; - } - }; - - template - struct compute_vec4_shift_left - { - static tvec4 call(tvec4 const& a, tvec4 const& b) - { - tvec4 Result(uninitialize); + tvec4 Result(uninitialize); Result.data = _mm_sll_epi32(a.data, b.data); return Result; } }; - template - struct compute_vec4_shift_left + template + struct compute_vec4_shift_right { - static tvec4 call(tvec4 const& a, tvec4 const& b) - { - tvec4 Result(uninitialize); - Result.data = _mm_sll_epi32(a.data, b.data); - return Result; - } - }; - - template - struct compute_vec4_shift_right - { - static tvec4 call(tvec4 const& a, tvec4 const& b) + static tvec4 call(tvec4 const& a, tvec4 const& b) { - tvec4 Result(uninitialize); + tvec4 Result(uninitialize); Result.data = _mm_srl_epi32(a.data, b.data); return Result; } }; - template - struct compute_vec4_shift_right + template + struct compute_vec4_logical_not { - static tvec4 call(tvec4 const& a, tvec4 const& b) + static tvec4 call(tvec4 const & v) { - tvec4 Result(uninitialize); - Result.data = _mm_srl_epi32(a.data, b.data); + tvec4 Result(uninitialize); + Result.data = _mm_xor_si128(v.data, _mm_set1_epi32(-1)); return Result; } }; diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index edd5c72a..27a5c9d2 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -1237,6 +1237,12 @@ int main() { int Error = 0; + glm::ivec4 const a(1); + glm::ivec4 const b = ~a; + + glm::int32 const c(1); + glm::int32 const d = ~c; + Error += sign::test(); Error += floor_::test(); Error += mod_::test();