diff --git a/CMakeLists.txt b/CMakeLists.txt index e77c9b97..a9f5236c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,7 @@ else() add_definitions(/Za) elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")) add_definitions(-pedantic) + add_definitions(-pedantic) endif() endif() diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index 0891eb01..25910eb0 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -12,6 +12,15 @@ #endif//(GLM_ARCH & GLM_ARCH_X86 && GLM_COMPILER & GLM_COMPILER_VC) #include +#if !GLM_HAS_EXTENDED_INTEGER_TYPE +# if GLM_COMPILER & GLM_COMPILER_GCC +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +# if (GLM_COMPILER & GLM_COMPILER_CLANG) +# pragma clang diagnostic ignored "-Wc++11-long-long" +# endif +#endif + namespace glm{ namespace detail { diff --git a/glm/detail/precision.hpp b/glm/detail/precision.hpp index 8b1e2929..7c54437c 100644 --- a/glm/detail/precision.hpp +++ b/glm/detail/precision.hpp @@ -3,52 +3,61 @@ #pragma once +#include "setup.hpp" + namespace glm { enum precision { - highp, - mediump, - lowp, - aligned_highp, - aligned_mediump, - aligned_lowp, - packed_highp = highp, - packed_mediump = mediump, - packed_lowp = lowp, + packed_highp, + packed_mediump, + packed_lowp, + +# if GLM_HAS_ALIGNED_TYPE + aligned_highp, + aligned_mediump, + aligned_lowp, + aligned = aligned_highp, +# endif + + highp = packed_highp, + mediump = packed_mediump, + lowp = packed_lowp, packed = packed_highp, - aligned = aligned_highp, -# ifdef GLM_FORCE_ALIGNED + +# if GLM_HAS_ALIGNED_TYPE && defined(GLM_FORCE_ALIGNED) defaultp = aligned_highp # else defaultp = highp # endif }; - + namespace detail { - template + template struct is_aligned { static const bool value = false; }; - template<> - struct is_aligned - { - static const bool value = true; - }; +# if GLM_HAS_ALIGNED_TYPE + template<> + struct is_aligned + { + static const bool value = true; + }; - template<> - struct is_aligned - { - static const bool value = true; - }; + template<> + struct is_aligned + { + static const bool value = true; + }; - template<> - struct is_aligned - { - static const bool value = true; - }; + template<> + struct is_aligned + { + static const bool value = true; + }; +# endif }//namespace detail }//namespace glm diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 338b9805..e277160f 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -647,6 +647,10 @@ # define GLM_EXPLICIT #endif +/////////////////////////////////////////////////////////////////////////////////// + +#define GLM_HAS_ALIGNED_TYPE GLM_HAS_UNRESTRICTED_UNIONS + /////////////////////////////////////////////////////////////////////////////////// // Length type diff --git a/glm/detail/type_int.hpp b/glm/detail/type_int.hpp index 56939255..764a32cf 100644 --- a/glm/detail/type_int.hpp +++ b/glm/detail/type_int.hpp @@ -35,7 +35,7 @@ namespace detail typedef unsigned __int64 uint64; # elif GLM_COMPILER & GLM_COMPILER_GCC -# pragma GCC diagnostic ignored "-Wno-long-long" +# pragma GCC diagnostic ignored "-Wlong-long" __extension__ typedef signed long long sint64; __extension__ typedef unsigned long long uint64; diff --git a/glm/detail/type_vec.hpp b/glm/detail/type_vec.hpp index 99aa4d48..82e4ba01 100644 --- a/glm/detail/type_vec.hpp +++ b/glm/detail/type_vec.hpp @@ -16,7 +16,7 @@ namespace detail uint8 data[size]; } type; }; -/* + template struct storage { @@ -24,7 +24,7 @@ namespace detail uint8 data[size]; } type; }; -*/ + # if GLM_ARCH & GLM_ARCH_SSE2_BIT template <> struct storage @@ -43,6 +43,31 @@ namespace detail { typedef glm_uvec4 type; }; +/* +# else + typedef union __declspec(align(16)) glm_128 + { + unsigned __int8 data[16]; + } glm_128; + + template <> + struct storage + { + typedef glm_128 type; + }; + + template <> + struct storage + { + typedef glm_128 type; + }; + + template <> + struct storage + { + typedef glm_128 type; + }; +*/ # endif # if (GLM_ARCH & GLM_ARCH_AVX_BIT) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index d757abb1..dff3140d 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -21,16 +21,16 @@ namespace glm { // -- Implementation detail -- + typedef T value_type; typedef tvec1 type; typedef tvec1 bool_type; - typedef T value_type; // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-pedantic" # endif # if GLM_COMPILER & GLM_COMPILER_CLANG # pragma clang diagnostic push diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index e07ab389..718919e4 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -26,10 +26,10 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-pedantic" # endif # if GLM_COMPILER & GLM_COMPILER_CLANG # pragma clang diagnostic push diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 80086679..79d9ee32 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -20,16 +20,16 @@ namespace glm { // -- Implementation detail -- + typedef T value_type; typedef tvec3 type; typedef tvec3 bool_type; - typedef T value_type; // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-pedantic" # endif # if GLM_COMPILER & GLM_COMPILER_CLANG # pragma clang diagnostic push diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 887e497a..027136e0 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -3,7 +3,6 @@ #pragma once -#include "setup.hpp" #include "type_vec.hpp" #ifdef GLM_SWIZZLE # if GLM_HAS_ANONYMOUS_UNION @@ -27,10 +26,10 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-pedantic" # endif # if GLM_COMPILER & GLM_COMPILER_CLANG # pragma clang diagnostic push diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 00320835..d891e038 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -970,6 +970,6 @@ namespace detail } }//namespace glm -#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_UNRESTRICTED_UNIONS +#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_ALIGNED_TYPE # include "type_vec4_simd.inl" #endif diff --git a/glm/detail/type_vec4_simd.inl b/glm/detail/type_vec4_simd.inl index 21504f03..97b65f44 100644 --- a/glm/detail/type_vec4_simd.inl +++ b/glm/detail/type_vec4_simd.inl @@ -49,7 +49,7 @@ namespace detail return Result; } }; -# endif +# endif//GLM_SWIZZLE template struct compute_vec4_add diff --git a/glm/ext.hpp b/glm/ext.hpp index 59476b0a..dee032e3 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -50,6 +50,9 @@ #include "./gtc/type_ptr.hpp" #include "./gtc/ulp.hpp" #include "./gtc/vec1.hpp" +#if GLM_HAS_ALIGNED_TYPE +# include "./gtc/type_aligned.hpp" +#endif #include "./gtx/associated_min_max.hpp" #include "./gtx/bit.hpp" @@ -95,7 +98,6 @@ #endif #include "./gtx/transform.hpp" #include "./gtx/transform2.hpp" -#include "./gtx/type_aligned.hpp" #include "./gtx/vector_angle.hpp" #include "./gtx/vector_query.hpp" #include "./gtx/wrap.hpp" diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index b4762a87..fee13db7 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -40,10 +40,10 @@ namespace glm // -- Data -- -# if GLM_HAS_UNRESTRICTED_UNIONS && (defined(GLM_SWIZZLE) || (GLM_ARCH & (GLM_ARCH_SSE2_BIT | GLM_ARCH_NEON_BIT))) +# if GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-pedantic" # endif # if GLM_COMPILER & GLM_COMPILER_CLANG # pragma clang diagnostic push diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 60cae12f..ff610980 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -795,7 +795,7 @@ namespace detail } }//namespace glm -#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_UNRESTRICTED_UNIONS +#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_ALIGNED_TYPE # include "quaternion_simd.inl" #endif diff --git a/glm/gtc/type_aligned.hpp b/glm/gtc/type_aligned.hpp index 14603434..d143bcf3 100644 --- a/glm/gtc/type_aligned.hpp +++ b/glm/gtc/type_aligned.hpp @@ -1,5 +1,21 @@ /// @ref gtc_type_aligned /// @file glm/gtc/type_aligned.hpp +/// +/// @see core (dependence) +/// +/// @defgroup gtc_type_aligned GLM_GTC_type_aligned +/// @ingroup gtc +/// +/// @brief Aligned types. +/// need to be included to use these features. + +#if !GLM_HAS_ALIGNED_TYPE +# error "GLM: Aligned types are not supported on this platform" +#endif + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_type_aligned extension included") +#endif #pragma once diff --git a/test/gtc/gtc_type_aligned.cpp b/test/gtc/gtc_type_aligned.cpp index 303b7aec..351a3958 100644 --- a/test/gtc/gtc_type_aligned.cpp +++ b/test/gtc/gtc_type_aligned.cpp @@ -1,6 +1,16 @@ -#define GLM_FORCE_ALIGNED +#define GLM_MESSAGES +#include + +#if GLM_HAS_ALIGNED_TYPE #include +GLM_STATIC_ASSERT(glm::detail::is_aligned::value, "aligned_lowp is not aligned"); +GLM_STATIC_ASSERT(glm::detail::is_aligned::value, "aligned_mediump is not aligned"); +GLM_STATIC_ASSERT(glm::detail::is_aligned::value, "aligned_highp is not aligned"); +GLM_STATIC_ASSERT(!glm::detail::is_aligned::value, "packed_highp is aligned"); +GLM_STATIC_ASSERT(!glm::detail::is_aligned::value, "packed_mediump is aligned"); +GLM_STATIC_ASSERT(!glm::detail::is_aligned::value, "packed_lowp is aligned"); + struct my_vec4_packed { glm::uint32 a; @@ -27,7 +37,6 @@ struct my_dvec4_aligned glm::uint64 a; glm::aligned_dvec4 b; }; -//FIXME //GLM_STATIC_ASSERT(sizeof(my_dvec4_aligned) == sizeof(glm::aligned_dvec4) * 2, "glm::dvec4 aligned is not correct"); struct my_ivec4_packed @@ -81,7 +90,6 @@ int test_copy() return Error; } - int main() { int Error = 0; @@ -99,3 +107,12 @@ int main() return Error; } + +#else + +int main() +{ + return 0; +} + +#endif//GLM_HAS_ALIGNED_TYPE diff --git a/test/gtx/gtx_io.cpp b/test/gtx/gtx_io.cpp index 8b0b12fa..a7ab7a76 100644 --- a/test/gtx/gtx_io.cpp +++ b/test/gtx/gtx_io.cpp @@ -17,9 +17,11 @@ namespace case glm::highp: os << "uhi"; break; case glm::mediump: os << "umd"; break; case glm::lowp: os << "ulo"; break; - case glm::aligned_highp: os << "ahi"; break; - case glm::aligned_mediump: os << "amd"; break; - case glm::aligned_lowp: os << "alo"; break; +# if GLM_HAS_ALIGNED_TYPE + case glm::aligned_highp: os << "ahi"; break; + case glm::aligned_mediump: os << "amd"; break; + case glm::aligned_lowp: os << "alo"; break; +# endif } }