From 2a3d241d78201ff9e8e9a34041686fbe670cb77e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 16 Jul 2016 18:46:15 +0200 Subject: [PATCH] GLM requires anynimous struct for SIMD optimizations and swizzle support #524 --- glm/detail/type_vec1.hpp | 2 +- glm/detail/type_vec2.hpp | 2 +- glm/detail/type_vec3.hpp | 2 +- glm/detail/type_vec4.hpp | 2 +- glm/gtc/quaternion.hpp | 19 ++++++++++++++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index e23b8294..d757abb1 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -27,7 +27,7 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS +# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index e2be2486..e07ab389 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -26,7 +26,7 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS +# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 213b619d..80086679 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -26,7 +26,7 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS +# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index f52792a2..887e497a 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -27,7 +27,7 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS +# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 179722a8..85ee7efc 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -40,12 +40,29 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS +# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_COMPILER & GLM_COMPILER_GCC +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +# endif +# if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wgnu-anonymous-struct" +# pragma clang diagnostic ignored "-Wnested-anon-types" +# endif + union { struct { T x, y, z, w;}; typename detail::storage::value>::type data; }; + +# if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +# endif +# if GLM_COMPILER & GLM_COMPILER_GCC +# pragma GCC diagnostic pop +# endif # else T x, y, z, w; # endif