diff --git a/glm/detail/qualifier.hpp b/glm/detail/qualifier.hpp index 287decdf..2437fc06 100644 --- a/glm/detail/qualifier.hpp +++ b/glm/detail/qualifier.hpp @@ -15,7 +15,7 @@ namespace glm packed_mediump, ///< Typed data is tightly packed in memory and operations are executed with medium precision in term of ULPs for higher performance packed_lowp, ///< Typed data is tightly packed in memory and operations are executed with low precision in term of ULPs to maximize performance -# if GLM_HAS_ANONYMOUS_STRUCT +# if (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE) aligned_highp, ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs aligned_mediump, ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs for higher performance aligned_lowp, // ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs to maximize performance @@ -27,7 +27,7 @@ namespace glm lowp = packed_lowp, ///< By default lowp qualifier is also packed packed = packed_highp, ///< By default packed qualifier is also high precision -# if GLM_HAS_ANONYMOUS_STRUCT && defined(GLM_FORCE_ALIGNED) +# if (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE) && defined(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES) defaultp = aligned_highp # else defaultp = highp @@ -47,7 +47,7 @@ namespace detail static const bool value = false; }; -# if GLM_HAS_ANONYMOUS_STRUCT +# if GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE template<> struct is_aligned { @@ -65,7 +65,7 @@ namespace detail { static const bool value = true; }; -# endif//GLM_HAS_ANONYMOUS_STRUCT +# endif template struct storage @@ -75,7 +75,7 @@ namespace detail } type; }; -# if GLM_LANG & GLM_LANG_CXX11_FLAG +# if GLM_HAS_ALIGNOF template struct storage { diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 38563336..c8ad0c90 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -370,10 +370,6 @@ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14) && (GLM_ARCH & GLM_ARCH_X86_BIT)))) #endif -/////////////////////////////////////////////////////////////////////////////////// - -#define GLM_HAS_ANONYMOUS_STRUCT (GLM_LANG & GLM_LANG_CXXMS_FLAG) - /////////////////////////////////////////////////////////////////////////////////// // OpenMP #ifdef _OPENMP @@ -482,7 +478,7 @@ #define GLM_SWIZZLE_OPERATOR 1 #define GLM_SWIZZLE_FUNCTION 2 -#if defined(GLM_FORCE_SWIZZLE) && GLM_HAS_ANONYMOUS_STRUCT +#if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG) # define GLM_SWIZZLE GLM_SWIZZLE_OPERATOR #elif defined(GLM_FORCE_SWIZZLE) # define GLM_SWIZZLE GLM_SWIZZLE_FUNCTION @@ -582,8 +578,10 @@ #endif #if GLM_HAS_DEFAULTED_FUNCTIONS && !defined(GLM_FORCE_CTOR_INIT) +# define GLM_USE_DEFAULTED_FUNCTIONS GLM_ENABLE # define GLM_DEFAULT = default #else +# define GLM_USE_DEFAULTED_FUNCTIONS GLM_DISABLE # define GLM_DEFAULT #endif @@ -638,6 +636,24 @@ namespace glm # error "GLM error: A different version of GLM is already included. Define GLM_FORCE_IGNORE_VERSION before including GLM headers to ignore this error." #elif GLM_SETUP_INCLUDED == GLM_VERSION +/////////////////////////////////////////////////////////////////////////////////// +// Enable aligned gentypes + +#if defined(GLM_FORCE_ALIGNED_GENTYPES) && GLM_HAS_ALIGNOF +# define GLM_USE_ALIGNED_GENTYPES GLM_ENABLE +#else +# define GLM_USE_ALIGNED_GENTYPES GLM_DISABLE +#endif + +/////////////////////////////////////////////////////////////////////////////////// +// Implementation detail + +#if (((GLM_LANG & GLM_LANG_CXXMS_FLAG) && (GLM_ARCH & GLM_ARCH_SIMD_BIT)) || (GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR) || (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE)) +# define GLM_USE_ANONYMOUS_STRUCT GLM_ENABLE +#else +# define GLM_USE_ANONYMOUS_STRUCT GLM_DISABLE +#endif + /////////////////////////////////////////////////////////////////////////////////// // Messages diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index f1a671f8..918f0616 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -5,21 +5,19 @@ namespace glm { // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<1, T, Q>::vec() # ifdef GLM_FORCE_CTOR_INIT : x(0) # endif {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<1, T, Q>::vec(vec<1, T, Q> const& v) : x(v.x) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -78,12 +76,14 @@ namespace glm // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER vec<1, T, Q> & vec<1, T, Q>::operator=(vec<1, T, Q> const& v) - { - this->x = v.x; - return *this; - } +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE + template + GLM_FUNC_QUALIFIER vec<1, T, Q> & vec<1, T, Q>::operator=(vec<1, T, Q> const& v) + { + this->x = v.x; + return *this; + } +# endif template template diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index e779f7f9..75eebe00 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -24,7 +24,7 @@ namespace glm // -- Data -- -# if GLM_HAS_ANONYMOUS_STRUCT +# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct{ T x, y; }; @@ -114,7 +114,7 @@ namespace glm // -- Unary arithmetic operators -- - GLM_FUNC_DECL vec<2, T, Q> & operator=(vec const& v); + GLM_FUNC_DECL vec<2, T, Q> & operator=(vec const& v) GLM_DEFAULT; template GLM_FUNC_DECL vec<2, T, Q> & operator=(vec<2, U, Q> const& v); diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 82f8ebe1..bcd50d09 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -7,21 +7,19 @@ namespace glm { // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<2, T, Q>::vec() # ifdef GLM_FORCE_CTOR_INIT : x(0), y(0) # endif {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<2, T, Q>::vec(vec<2, T, Q> const& v) : x(v.x), y(v.y) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -119,13 +117,15 @@ namespace glm // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER vec<2, T, Q> & vec<2, T, Q>::operator=(vec<2, T, Q> const& v) - { - this->x = v.x; - this->y = v.y; - return *this; - } +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE + template + GLM_FUNC_QUALIFIER vec<2, T, Q> & vec<2, T, Q>::operator=(vec<2, T, Q> const& v) + { + this->x = v.x; + this->y = v.y; + return *this; + } +# endif template template diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 38279001..b652a7a6 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -24,7 +24,7 @@ namespace glm // -- Data -- -# if GLM_HAS_ANONYMOUS_STRUCT +# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct{ T x, y, z; }; @@ -81,7 +81,7 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 explicit vec(vec<1, U, P> const& v); - /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + /// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 vec(X x, Y y, Z z); template @@ -144,7 +144,7 @@ namespace glm // -- Unary arithmetic operators -- - GLM_FUNC_DECL vec<3, T, Q>& operator=(vec<3, T, Q> const& v); + GLM_FUNC_DECL vec<3, T, Q>& operator=(vec<3, T, Q> const& v) GLM_DEFAULT; template GLM_FUNC_DECL vec<3, T, Q> & operator=(vec<3, U, Q> const& v); diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 26fd12af..b01dfe75 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -5,21 +5,19 @@ namespace glm { // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<3, T, Q>::vec() # ifdef GLM_FORCE_CTOR_INIT : x(0), y(0), z(0) # endif {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<3, T, Q>::vec(vec<3, T, Q> const& v) : x(v.x), y(v.y), z(v.z) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -181,14 +179,16 @@ namespace glm // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, T, Q> const& v) - { - this->x = v.x; - this->y = v.y; - this->z = v.z; - return *this; - } +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE + template + GLM_FUNC_QUALIFIER vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, T, Q> const& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + return *this; + } +# endif template template diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 19df2af4..d0be3ca7 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -24,7 +24,7 @@ namespace glm // -- Data -- -# if GLM_HAS_ANONYMOUS_STRUCT +# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct { T x, y, z, w; }; @@ -219,7 +219,7 @@ namespace glm // -- Unary arithmetic operators -- - GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, T, Q> const& v); + GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, T, Q> const& v) GLM_DEFAULT; template GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, U, Q> const& v); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index f0c37755..0422d8c3 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -158,21 +158,19 @@ namespace detail // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<4, T, Q>::vec() # ifdef GLM_FORCE_CTOR_INIT : x(0), y(0), z(0), w(0) # endif {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<4, T, Q>::vec(vec<4, T, Q> const& v) : x(v.x), y(v.y), z(v.z), w(v.w) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -520,15 +518,17 @@ namespace detail // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, T, Q> const& v) - { - this->x = v.x; - this->y = v.y; - this->z = v.z; - this->w = v.w; - return *this; - } +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE + template + GLM_FUNC_QUALIFIER vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, T, Q> const& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + this->w = v.w; + return *this; + } +# endif template template diff --git a/glm/ext/vec1.hpp b/glm/ext/vec1.hpp index 4d6134d0..c03681dd 100644 --- a/glm/ext/vec1.hpp +++ b/glm/ext/vec1.hpp @@ -41,7 +41,7 @@ namespace glm // -- Data -- -# if GLM_HAS_ANONYMOUS_STRUCT +# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { T x; @@ -120,7 +120,7 @@ namespace glm */ // -- Unary arithmetic operators -- - GLM_FUNC_DECL vec<1, T, Q> & operator=(vec const& v); + GLM_FUNC_DECL vec<1, T, Q> & operator=(vec const& v) GLM_DEFAULT; template GLM_FUNC_DECL vec<1, T, Q> & operator=(vec<1, U, Q> const& v); diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index b7147a46..16357786 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -84,21 +84,19 @@ namespace detail // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tquat::tquat() # ifdef GLM_FORCE_CTOR_INIT : x(0), y(0), z(0), w(1) # endif {} -# endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tquat::tquat(tquat const& q) : x(q.x), y(q.y), z(q.z), w(q.w) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -223,7 +221,7 @@ namespace detail // -- Unary arithmetic operators -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER tquat & tquat::operator=(tquat const& q) { @@ -233,7 +231,7 @@ namespace detail this->z = q.z; return *this; } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template diff --git a/glm/gtc/type_aligned.hpp b/glm/gtc/type_aligned.hpp index c953a1a0..2129f2da 100644 --- a/glm/gtc/type_aligned.hpp +++ b/glm/gtc/type_aligned.hpp @@ -12,9 +12,10 @@ #pragma once -#if !GLM_HAS_ANONYMOUS_STRUCT -# error "GLM: Aligned types are not supported on this platform" +#if !GLM_USE_ANONYMOUS_STRUCT +# error "GLM: Aligned gentypes require to enable C++ language extensions and to define GLM_FORCE_ALIGNED_GENTYPES before including GLM headers." #endif + #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_GTC_type_aligned extension included") #endif diff --git a/glm/gtx/dual_quaternion.inl b/glm/gtx/dual_quaternion.inl index 86b7a8a7..b0dea070 100644 --- a/glm/gtx/dual_quaternion.inl +++ b/glm/gtx/dual_quaternion.inl @@ -24,7 +24,7 @@ namespace glm // -- Implicit basic constructors -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tdualquat::tdualquat() # ifdef GLM_FORCE_CTOR_INIT @@ -32,15 +32,13 @@ namespace glm , dual(tquat(0, 0, 0, 0)) # endif {} -# endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 tdualquat::tdualquat(tdualquat const& d) : real(d.real) , dual(d.dual) {} -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template @@ -93,7 +91,7 @@ namespace glm // -- Unary arithmetic operators -- -# if !GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER tdualquat & tdualquat::operator=(tdualquat const& q) { @@ -101,7 +99,7 @@ namespace glm this->dual = q.dual; return *this; } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS +# endif template template diff --git a/test/core/core_type_ctor.cpp b/test/core/core_type_ctor.cpp index 6cf4d4dc..6a5723dc 100644 --- a/test/core/core_type_ctor.cpp +++ b/test/core/core_type_ctor.cpp @@ -6,7 +6,7 @@ static int test_vec1_ctor() { int Error = 0; -# if GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE { union pack { @@ -20,7 +20,7 @@ static int test_vec1_ctor() B.f = glm::vec1(1); Error += glm::all(glm::equal(B.i, glm::ivec1(1065353216))) ? 0 : 1; } -# endif//GLM_HAS_DEFAULTED_FUNCTIONS +# endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE return Error; } @@ -29,7 +29,7 @@ static int test_vec2_ctor() { int Error = 0; -# if GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE { union pack { @@ -43,7 +43,7 @@ static int test_vec2_ctor() B.f = glm::vec2(1); Error += glm::all(glm::equal(B.i, glm::ivec2(1065353216))) ? 0 : 1; } -# endif//GLM_HAS_DEFAULTED_FUNCTIONS +# endif return Error; } @@ -52,7 +52,7 @@ static int test_vec3_ctor() { int Error = 0; -# if GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE { union pack { @@ -66,7 +66,7 @@ static int test_vec3_ctor() B.f = glm::vec3(1); Error += glm::all(glm::equal(B.i, glm::ivec3(1065353216))) ? 0 : 1; } -# endif//GLM_HAS_DEFAULTED_FUNCTIONS +# endif return Error; } @@ -75,7 +75,7 @@ static int test_vec4_ctor() { int Error = 0; -# if GLM_HAS_DEFAULTED_FUNCTIONS +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE { union pack { @@ -89,7 +89,7 @@ static int test_vec4_ctor() B.f = glm::vec4(1); Error += glm::all(glm::equal(B.i, glm::ivec4(1065353216))) ? 0 : 1; } -# endif//GLM_HAS_DEFAULTED_FUNCTIONS +# endif return Error; } diff --git a/test/gtc/gtc_type_aligned.cpp b/test/gtc/gtc_type_aligned.cpp index 19a4048f..da2dbd2c 100644 --- a/test/gtc/gtc_type_aligned.cpp +++ b/test/gtc/gtc_type_aligned.cpp @@ -1,7 +1,8 @@ #define GLM_FORCE_MESSAGES +#define GLM_FORCE_ALIGNED_GENTYPES #include -#if GLM_HAS_ANONYMOUS_STRUCT +#if GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE #include GLM_STATIC_ASSERT(glm::detail::is_aligned::value, "aligned_lowp is not aligned"); @@ -143,4 +144,4 @@ int main() return 0; } -#endif//GLM_HAS_ANONYMOUS_STRUCT +#endif//GLM_USE_ANONYMOUS_STRUCT