Added C++17 detection, added VC language version detection, clean up alignment type, clean up swizzle operator detection

This commit is contained in:
Groove 2018-07-11 02:53:22 +02:00
parent bd2c7070d7
commit 16106b2e3e
21 changed files with 246 additions and 387 deletions

View File

@ -125,142 +125,94 @@
#define GLM_LANG_CXX03_FLAG (1 << 2) #define GLM_LANG_CXX03_FLAG (1 << 2)
#define GLM_LANG_CXX0X_FLAG (1 << 3) #define GLM_LANG_CXX0X_FLAG (1 << 3)
#define GLM_LANG_CXX11_FLAG (1 << 4) #define GLM_LANG_CXX11_FLAG (1 << 4)
#define GLM_LANG_CXX1Y_FLAG (1 << 5) #define GLM_LANG_CXX14_FLAG (1 << 5)
#define GLM_LANG_CXX14_FLAG (1 << 6) #define GLM_LANG_CXX17_FLAG (1 << 6)
#define GLM_LANG_CXX1Z_FLAG (1 << 7) #define GLM_LANG_CXXMS_FLAG (1 << 7)
#define GLM_LANG_CXXMS_FLAG (1 << 8) #define GLM_LANG_CXXGNU_FLAG (1 << 8)
#define GLM_LANG_CXXGNU_FLAG (1 << 9)
#define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG #define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG
#define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG) #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG)
#define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG) #define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG)
#define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG) #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG)
#define GLM_LANG_CXX1Y (GLM_LANG_CXX11 | GLM_LANG_CXX1Y_FLAG) #define GLM_LANG_CXX14 (GLM_LANG_CXX11 | GLM_LANG_CXX14_FLAG)
#define GLM_LANG_CXX14 (GLM_LANG_CXX1Y | GLM_LANG_CXX14_FLAG) #define GLM_LANG_CXX17 (GLM_LANG_CXX14 | GLM_LANG_CXX17_FLAG)
#define GLM_LANG_CXX1Z (GLM_LANG_CXX14 | GLM_LANG_CXX1Z_FLAG)
#define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG
#define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
#if defined(GLM_FORCE_CXX14) #ifdef _MSC_EXTENSIONS
# if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC50)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG34)) # define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
# pragma message("GLM: Using GLM_FORCE_CXX14 with a compiler that doesn't fully support C++14") #else
# elif GLM_COMPILER & GLM_COMPILER_VC # define GLM_MSC_EXT 0
# pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of Visual C++ compiler that fully supports C++14") #endif
# elif GLM_COMPILER & GLM_COMPILER_INTEL
# pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of ICC compiler that fully supports C++14") #ifdef _MSVC_LANG
# if _MSVC_LANG == 201703
# define GLM_FORCE_CXX17
# elif _MSVC_LANG == 201402
# define GLM_FORCE_CXX14
# endif # endif
# define GLM_LANG GLM_LANG_CXX14 #endif
#if defined(GLM_FORCE_CXX17)
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED)
# define GLM_MESSAGE_FORCE_CXX17_DISPLAYED
# if (__cplusplus >= 201703L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15_7)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC80)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG50))
# pragma message("GLM: Force the use of C++17 only")
# else
# pragma message("GLM: Force the use of C++17 on a compiler that doesn't have full C++17 support")
# endif
# endif//GLM_MESSAGES
# define GLM_LANG (GLM_LANG_CXX17 | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX14)
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX14_DISPLAYED)
# define GLM_MESSAGE_FORCE_CXX14_DISPLAYED
# if (__cplusplus >= 201402L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC50)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG34))
# pragma message("GLM: Force the use of C++14 only")
# else
# pragma message("GLM: Force the use of C++14 on a compiler that doesn't have full C++14 support")
# endif
# endif//GLM_MESSAGES
# define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX11) #elif defined(GLM_FORCE_CXX11)
# if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC48)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG33)) # if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX11_DISPLAYED)
# pragma message("GLM: Using GLM_FORCE_CXX11 with a compiler that doesn't fully support C++11") # define GLM_MESSAGE_FORCE_CXX11_DISPLAYED
# elif GLM_COMPILER & GLM_COMPILER_VC # if (__cplusplus >= 201103L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG33))
# pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of Visual C++ compiler that fully supports C++11") # pragma message("GLM: Force the use of C++11 only")
# elif GLM_COMPILER & GLM_COMPILER_INTEL # else
# pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of ICC compiler that fully supports C++11") # pragma message("GLM: Force the use of C++11 on a compiler that doesn't have full C++11 support")
# endif # endif
# define GLM_LANG GLM_LANG_CXX11 # endif//GLM_MESSAGES
# define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX03) #elif defined(GLM_FORCE_CXX03)
# define GLM_LANG GLM_LANG_CXX03 # define GLM_LANG GLM_LANG_CXX03
#elif defined(GLM_FORCE_CXX98) #elif defined(GLM_FORCE_CXX98)
# define GLM_LANG GLM_LANG_CXX98 # define GLM_LANG GLM_LANG_CXX98
#else #else
# if GLM_COMPILER & GLM_COMPILER_CLANG # if __cplusplus >= 201703L
# if __cplusplus >= 201402L // GLM_COMPILER_CLANG34 + -std=c++14 # define GLM_LANG (GLM_LANG_CXX17 | GLM_MSC_EXT)
# define GLM_LANG GLM_LANG_CXX14 # elif __cplusplus >= 201402L
# elif __has_feature(cxx_decltype_auto) && __has_feature(cxx_aggregate_nsdmi) // GLM_COMPILER_CLANG33 + -std=c++1y
# define GLM_LANG GLM_LANG_CXX1Y
# elif __cplusplus >= 201103L // GLM_COMPILER_CLANG33 + -std=c++11
# define GLM_LANG GLM_LANG_CXX11
# elif __has_feature(cxx_static_assert) // GLM_COMPILER_CLANG29 + -std=c++11
# define GLM_LANG GLM_LANG_CXX0X
# elif __cplusplus >= 199711L
# define GLM_LANG GLM_LANG_CXX98
# else
# define GLM_LANG GLM_LANG_CXX
# endif
# elif GLM_COMPILER & GLM_COMPILER_GCC
# if __cplusplus >= 201402L
# define GLM_LANG GLM_LANG_CXX14
# elif __cplusplus >= 201103L
# define GLM_LANG GLM_LANG_CXX11
# elif defined(__GXX_EXPERIMENTAL_CXX0X__)
# define GLM_LANG GLM_LANG_CXX0X
# else
# define GLM_LANG GLM_LANG_CXX98
# endif
# elif GLM_COMPILER & GLM_COMPILER_VC
# ifdef _MSC_EXTENSIONS
# if __cplusplus >= 201402L
# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
# elif __cplusplus >= 201103L
# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
# else
# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
# endif
# else
# if __cplusplus >= 201402L
# define GLM_LANG GLM_LANG_CXX14
# elif __cplusplus >= 201103L
# define GLM_LANG GLM_LANG_CXX11
# else
# define GLM_LANG GLM_LANG_CXX0X
# endif
# endif
# elif GLM_COMPILER & GLM_COMPILER_INTEL
# ifdef _MSC_EXTENSIONS
# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
# else
# define GLM_MSC_EXT 0
# endif
# if __cplusplus >= 201402L
# define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT)
# elif __cplusplus >= 201103L # elif __cplusplus >= 201103L
# define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT)
# elif __INTEL_CXX11_MODE__ # elif defined(__INTEL_CXX11_MODE__) || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)
# define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
# elif __cplusplus >= 199711L # elif __cplusplus >= 199711L
# define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
# else # else
# define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT)
# endif # endif
# elif GLM_COMPILER & GLM_COMPILER_CUDA
# ifdef _MSC_EXTENSIONS
# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
# else
# define GLM_MSC_EXT 0
# endif
# if GLM_COMPILER >= GLM_COMPILER_CUDA75
# define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
# else
# define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
# endif
# else // Unknown compiler
# if __cplusplus >= 201402L
# define GLM_LANG GLM_LANG_CXX14
# elif __cplusplus >= 201103L
# define GLM_LANG GLM_LANG_CXX11
# elif __cplusplus >= 199711L
# define GLM_LANG GLM_LANG_CXX98
# else
# define GLM_LANG GLM_LANG_CXX // Good luck with that!
# endif
# ifndef GLM_FORCE_PURE
# define GLM_FORCE_PURE
# endif
# endif
#endif #endif
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_LANG_DISPLAYED) #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_LANG_DISPLAYED)
# define GLM_MESSAGE_LANG_DISPLAYED # define GLM_MESSAGE_LANG_DISPLAYED
# if GLM_LANG & GLM_LANG_CXX1Z_FLAG # if GLM_LANG & GLM_LANG_CXX17_FLAG
# pragma message("GLM: C++1z") # pragma message("GLM: C++17")
# elif GLM_LANG & GLM_LANG_CXX14_FLAG # elif GLM_LANG & GLM_LANG_CXX14_FLAG
# pragma message("GLM: C++14") # pragma message("GLM: C++14")
# elif GLM_LANG & GLM_LANG_CXX1Y_FLAG
# pragma message("GLM: C++1y")
# elif GLM_LANG & GLM_LANG_CXX11_FLAG # elif GLM_LANG & GLM_LANG_CXX11_FLAG
# pragma message("GLM: C++11") # pragma message("GLM: C++11")
# elif GLM_LANG & GLM_LANG_CXX0X_FLAG # elif GLM_LANG & GLM_LANG_CXX0X_FLAG
@ -340,7 +292,7 @@
// N2544 Unrestricted unions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf // N2544 Unrestricted unions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
#if GLM_COMPILER & GLM_COMPILER_CLANG #if GLM_COMPILER & GLM_COMPILER_CLANG
# define GLM_HAS_UNRESTRICTED_UNIONS __has_feature(cxx_unrestricted_unions) # define GLM_HAS_UNRESTRICTED_UNIONS __has_feature(cxx_unrestricted_unions)
#elif GLM_LANG & (GLM_LANG_CXX11_FLAG | GLM_LANG_CXXMS_FLAG) #elif GLM_LANG & GLM_LANG_CXX11_FLAG
# define GLM_HAS_UNRESTRICTED_UNIONS 1 # define GLM_HAS_UNRESTRICTED_UNIONS 1
#else #else
# define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ # define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
@ -608,7 +560,7 @@
#define GLM_SWIZZLE_ENABLED 1 #define GLM_SWIZZLE_ENABLED 1
#define GLM_SWIZZLE_DISABLE 0 #define GLM_SWIZZLE_DISABLE 0
#if defined(GLM_FORCE_SWIZZLE) #if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)
# define GLM_SWIZZLE GLM_SWIZZLE_ENABLED # define GLM_SWIZZLE GLM_SWIZZLE_ENABLED
#else #else
# define GLM_SWIZZLE GLM_SWIZZLE_DISABLE # define GLM_SWIZZLE GLM_SWIZZLE_DISABLE
@ -619,7 +571,7 @@
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
# pragma message("GLM: Swizzling operators enabled") # pragma message("GLM: Swizzling operators enabled")
# else # else
# pragma message("GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators") # pragma message("GLM: Swizzling operators disabled, #define GLM_FORCE_SWIZZLE to enable swizzle operators")
# endif # endif
#endif//GLM_MESSAGES #endif//GLM_MESSAGES

View File

@ -10,92 +10,101 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template<typename T, std::size_t size, bool aligned> template<length_t L, typename T, qualifier Q>
struct storage_alignment
{};
template<length_t L, typename T>
struct alignas(L * sizeof(T)) storage_alignment<L, T, aligned_highp>
{};
template<length_t L, typename T>
struct alignas(L * sizeof(T)) storage_alignment<L, T, aligned_mediump>
{};
template<length_t L, typename T>
struct alignas(L * sizeof(T)) storage_alignment<L, T, aligned_lowp>
{};
template<length_t L, typename T, bool is_aligned>
struct storage struct storage
{ {
typedef struct type { typedef struct type {
uint8 data[size]; T data[L];
} type; } type;
}; };
#define GLM_ALIGNED_STORAGE_TYPE_STRUCT(x) \ template<length_t L, typename T>
template<typename T> \ struct storage<L, T, true>
struct storage<T, x, true> { \ {
GLM_ALIGNED_STRUCT(x) type { \ typedef struct alignas(L * sizeof(T)) type {
uint8 data[x]; \ T data[L];
}; \ } type;
}; };
GLM_ALIGNED_STORAGE_TYPE_STRUCT(1) template<typename T>
GLM_ALIGNED_STORAGE_TYPE_STRUCT(2) struct storage<3, T, true>
GLM_ALIGNED_STORAGE_TYPE_STRUCT(4) {
GLM_ALIGNED_STORAGE_TYPE_STRUCT(8) typedef struct alignas(4 * sizeof(T)) type {
GLM_ALIGNED_STORAGE_TYPE_STRUCT(16) T data[4];
GLM_ALIGNED_STORAGE_TYPE_STRUCT(32) } type;
GLM_ALIGNED_STORAGE_TYPE_STRUCT(64) };
# if GLM_ARCH & GLM_ARCH_SSE2_BIT # if GLM_ARCH & GLM_ARCH_SSE2_BIT
template<> template<>
struct storage<float, 16, true> struct storage<4, float, true>
{ {
typedef glm_vec4 type; typedef glm_f32vec4 type;
}; };
template<> template<>
struct storage<int, 16, true> struct storage<4, int32, true>
{ {
typedef glm_ivec4 type; typedef glm_i32vec4 type;
}; };
template<> template<>
struct storage<unsigned int, 16, true> struct storage<4, uint32, true>
{ {
typedef glm_uvec4 type; typedef glm_u32vec4 type;
};
/*
# else
typedef union __declspec(align(16)) glm_128
{
unsigned __int8 data[16];
} glm_128;
template<>
struct storage<float, 16, true>
{
typedef glm_128 type;
}; };
template<> template<>
struct storage<int, 16, true> struct storage<2, double, true>
{ {
typedef glm_128 type; typedef glm_f64vec2 type;
}; };
template<> template<>
struct storage<unsigned int, 16, true> struct storage<2, int64, true>
{ {
typedef glm_128 type; typedef glm_i64vec2 type;
};
template<>
struct storage<2, uint64, true>
{
typedef glm_u64vec2 type;
}; };
*/
# endif # endif
# if (GLM_ARCH & GLM_ARCH_AVX_BIT) # if (GLM_ARCH & GLM_ARCH_AVX_BIT)
template<> template<>
struct storage<double, 32, true> struct storage<4, double, true>
{ {
typedef glm_dvec4 type; typedef glm_f64vec4 type;
}; };
# endif # endif
# if (GLM_ARCH & GLM_ARCH_AVX2_BIT) # if (GLM_ARCH & GLM_ARCH_AVX2_BIT)
template<> template<>
struct storage<int64, 32, true> struct storage<4, int64, true>
{ {
typedef glm_i64vec4 type; typedef glm_i64vec4 type;
}; };
template<> template<>
struct storage<uint64, 32, true> struct storage<4, uint64, true>
{ {
typedef glm_u64vec4 type; typedef glm_u64vec4 type;
}; };

View File

@ -5,7 +5,7 @@
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
# if GLM_HAS_UNRESTRICTED_UNIONS # if GLM_LANG & GLM_LANG_CXXMS_FLAG
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
@ -29,23 +29,15 @@ namespace glm
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ONLY_XYZW
T x, y; T x, y;
# elif GLM_HAS_ALIGNED_TYPE # elif GLM_LANG & GLM_LANG_CXXMS_FLAG
# 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 union
{ {
struct{ T x, y; }; struct{ T x, y; };
struct{ T r, g; }; struct{ T r, g; };
struct{ T s, t; }; struct{ T s, t; };
typename detail::storage<2, T, detail::is_aligned<Q>::value>::type data;
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE2_2_MEMBERS(T, Q, x, y) GLM_SWIZZLE2_2_MEMBERS(T, Q, x, y)
GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g) GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g)
@ -57,22 +49,14 @@ namespace glm
GLM_SWIZZLE2_4_MEMBERS(T, Q, r, g) GLM_SWIZZLE2_4_MEMBERS(T, Q, r, g)
GLM_SWIZZLE2_4_MEMBERS(T, Q, s, t) GLM_SWIZZLE2_4_MEMBERS(T, Q, s, t)
# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
}; };
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else # else
union {T x, r, s;}; union {T x, r, s;};
union {T y, g, t;}; union {T y, g, t;};
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED //# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, P) // GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q)
# endif//GLM_SWIZZLE //# endif//GLM_SWIZZLE
# endif # endif
// -- Component accesses -- // -- Component accesses --

View File

@ -5,7 +5,7 @@
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
# if GLM_HAS_UNRESTRICTED_UNIONS # if GLM_LANG & GLM_LANG_CXXMS_FLAG
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
@ -29,23 +29,15 @@ namespace glm
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ONLY_XYZW
T x, y, z; T x, y, z;
# elif GLM_HAS_ALIGNED_TYPE # elif GLM_LANG & GLM_LANG_CXXMS_FLAG
# 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 union
{ {
struct{ T x, y, z; }; struct{ T x, y, z; };
struct{ T r, g, b; }; struct{ T r, g, b; };
struct{ T s, t, p; }; struct{ T s, t, p; };
typename detail::storage<3, T, detail::is_aligned<Q>::value>::type data;
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE3_2_MEMBERS(T, Q, x, y, z) GLM_SWIZZLE3_2_MEMBERS(T, Q, x, y, z)
GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b) GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b)
@ -58,21 +50,14 @@ namespace glm
GLM_SWIZZLE3_4_MEMBERS(T, Q, s, t, p) GLM_SWIZZLE3_4_MEMBERS(T, Q, s, t, p)
# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
}; };
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else # else
union { T x, r, s; }; union { T x, r, s; };
union { T y, g, t; }; union { T y, g, t; };
union { T z, b, p; }; union { T z, b, p; };
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED //# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P) // GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, Q)
# endif//GLM_SWIZZLE //# endif//GLM_SWIZZLE
# endif//GLM_LANG # endif//GLM_LANG
// -- Component accesses -- // -- Component accesses --

View File

@ -5,7 +5,7 @@
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
# if GLM_HAS_UNRESTRICTED_UNIONS # if GLM_LANG & GLM_LANG_CXXMS_FLAG
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
@ -16,7 +16,7 @@
namespace glm namespace glm
{ {
template<typename T, qualifier Q> template<typename T, qualifier Q>
struct vec<4, T, Q> struct vec<4, T, Q> : detail::storage_alignment<4, T, Q>
{ {
// -- Implementation detail -- // -- Implementation detail --
@ -29,24 +29,14 @@ namespace glm
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ONLY_XYZW
T x, y, z, w; T x, y, z, w;
# elif GLM_HAS_ALIGNED_TYPE # elif GLM_LANG & GLM_LANG_CXXMS_FLAG
# 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 union
{ {
struct { T x, y, z, w; }; struct { T x, y, z, w; };
struct { T r, g, b, a; }; struct { T r, g, b, a; };
struct { T s, t, p, q; }; struct { T s, t, p, q; };
typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<Q>::value>::type data; typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE4_2_MEMBERS(T, Q, x, y, z, w) GLM_SWIZZLE4_2_MEMBERS(T, Q, x, y, z, w)
@ -60,22 +50,15 @@ namespace glm
GLM_SWIZZLE4_4_MEMBERS(T, Q, s, t, p, q) GLM_SWIZZLE4_4_MEMBERS(T, Q, s, t, p, q)
# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
}; };
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else # else
union { T x, r, s; }; union { T x, r, s; };
union { T y, g, t; }; union { T y, g, t; };
union { T z, b, p; }; union { T z, b, p; };
union { T w, a, q; }; union { T w, a, q; };
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED //# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P) // GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, Q)
# endif//GLM_SWIZZLE //# endif//GLM_SWIZZLE
# endif # endif
// -- Component accesses -- // -- Component accesses --

View File

@ -15,7 +15,7 @@
#include "../fwd.hpp" #include "../fwd.hpp"
#include "../detail/type_vec.hpp" #include "../detail/type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
# if GLM_HAS_UNRESTRICTED_UNIONS # if GLM_LANG & GLM_LANG_CXXMS_FLAG
# include "../detail/_swizzle.hpp" # include "../detail/_swizzle.hpp"
# else # else
# include "../detail/_swizzle_func.hpp" # include "../detail/_swizzle_func.hpp"
@ -46,22 +46,14 @@ namespace glm
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ONLY_XYZW
T x; T x;
# elif GLM_HAS_ALIGNED_TYPE # elif GLM_LANG & GLM_LANG_CXXMS_FLAG
# 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 union
{ {
T x; T x;
T r; T r;
T s; T s;
typename detail::storage<1, T, detail::is_aligned<Q>::value>::type data;
/* /*
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, x) _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, x)
@ -75,18 +67,11 @@ namespace glm
_GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, s) _GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, s)
# endif//GLM_SWIZZLE*/ # endif//GLM_SWIZZLE*/
}; };
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else # else
union {T x, r, s;}; union {T x, r, s;};
/* /*
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4) GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, Q, tvec2, tvec2, tvec3, tvec4)
# endif//GLM_SWIZZLE*/ # endif//GLM_SWIZZLE*/
# endif # endif

View File

@ -39,29 +39,11 @@ namespace glm
// -- Data -- // -- Data --
# if GLM_HAS_ALIGNED_TYPE # if GLM_LANG & GLM_LANG_CXXMS_FLAG
# 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 union
{ {
struct { T x, y, z, w;}; struct { T x, y, z, w;};
typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<Q>::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 # else
T x, y, z, w; T x, y, z, w;
# endif # endif

View File

@ -7,52 +7,52 @@
#if GLM_ARCH & GLM_ARCH_SSE2_BIT #if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_add(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_add(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_add_ps(a, b); return _mm_add_ps(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_add(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_add(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_add_ss(a, b); return _mm_add_ss(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sub(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_sub(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_sub_ps(a, b); return _mm_sub_ps(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_sub(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_sub(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_sub_ss(a, b); return _mm_sub_ss(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_mul(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_mul(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_mul_ps(a, b); return _mm_mul_ps(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_mul(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_mul(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_mul_ss(a, b); return _mm_mul_ss(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_div(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_div(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_div_ps(a, b); return _mm_div_ps(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_div(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_div(glm_f32vec4 a, glm_f32vec4 b)
{ {
return _mm_div_ss(a, b); return _mm_div_ss(a, b);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_div_lowp(glm_vec4 a, glm_vec4 b) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_div_lowp(glm_f32vec4 a, glm_f32vec4 b)
{ {
return glm_vec4_mul(a, _mm_rcp_ps(b)); return glm_vec4_mul(a, _mm_rcp_ps(b));
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_swizzle_xyzw(glm_vec4 a) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_swizzle_xyzw(glm_f32vec4 a)
{ {
# if GLM_ARCH & GLM_ARCH_AVX2_BIT # if GLM_ARCH & GLM_ARCH_AVX2_BIT
return _mm_permute_ps(a, _MM_SHUFFLE(3, 2, 1, 0)); return _mm_permute_ps(a, _MM_SHUFFLE(3, 2, 1, 0));
@ -61,7 +61,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_swizzle_xyzw(glm_vec4 a)
# endif # endif
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_fma(glm_f32vec4 a, glm_f32vec4 b, glm_f32vec4 c)
{ {
# if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG) # if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG)
return _mm_fmadd_ss(a, b, c); return _mm_fmadd_ss(a, b, c);
@ -70,7 +70,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c)
# endif # endif
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_fma(glm_f32vec4 a, glm_f32vec4 b, glm_f32vec4 c)
{ {
# if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG) # if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG)
return _mm_fmadd_ps(a, b, c); return _mm_fmadd_ps(a, b, c);
@ -79,7 +79,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c)
# endif # endif
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_abs(glm_vec4 x) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_abs(glm_f32vec4 x)
{ {
return _mm_and_ps(x, _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF))); return _mm_and_ps(x, _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)));
} }

View File

@ -7,12 +7,12 @@
#if GLM_ARCH & GLM_ARCH_SSE2_BIT #if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_sqrt_lowp(glm_vec4 x) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_sqrt_lowp(glm_f32vec4 x)
{ {
return _mm_mul_ss(_mm_rsqrt_ss(x), x); return _mm_mul_ss(_mm_rsqrt_ss(x), x);
} }
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sqrt_lowp(glm_vec4 x) GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_sqrt_lowp(glm_f32vec4 x)
{ {
return _mm_mul_ps(_mm_rsqrt_ps(x), x); return _mm_mul_ps(_mm_rsqrt_ps(x), x);
} }

View File

@ -385,13 +385,22 @@
#endif//GLM_ARCH #endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE2_BIT #if GLM_ARCH & GLM_ARCH_SSE2_BIT
typedef __m128 glm_vec4; typedef __m128 glm_f32vec4;
typedef __m128i glm_ivec4; typedef __m128i glm_i32vec4;
typedef __m128i glm_uvec4; typedef __m128i glm_u32vec4;
typedef __m128d glm_f64vec2;
typedef __m128i glm_i64vec2;
typedef __m128i glm_u64vec2;
typedef glm_f32vec4 glm_vec4;
typedef glm_i32vec4 glm_ivec4;
typedef glm_u32vec4 glm_uvec4;
typedef glm_f64vec2 glm_dvec2;
#endif #endif
#if GLM_ARCH & GLM_ARCH_AVX_BIT #if GLM_ARCH & GLM_ARCH_AVX_BIT
typedef __m256d glm_dvec4; typedef __m256d glm_f64vec4;
typedef glm_f64vec4 glm_dvec4;
#endif #endif
#if GLM_ARCH & GLM_ARCH_AVX2_BIT #if GLM_ARCH & GLM_ARCH_AVX2_BIT

View File

@ -54,6 +54,8 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
### [GLM 0.9.9.1](https://github.com/g-truc/glm/commits/master) - 2018-0X-XX ### [GLM 0.9.9.1](https://github.com/g-truc/glm/commits/master) - 2018-0X-XX
#### Features: #### Features:
- Added bitfieldDeinterleave to GTC_bitfield - Added bitfieldDeinterleave to GTC_bitfield
- Added C++17 detection
- Added Visual C++ language standard version detection
#### Improvements: #### Improvements:
- Added missing vec1 based constructors - Added missing vec1 based constructors
@ -63,6 +65,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
#### Fixes: #### Fixes:
- Fixed build problems due to printf and std::clock_t #778 - Fixed build problems due to printf and std::clock_t #778
- Fixed int mod - Fixed int mod
- Anonymous unions require C++ language extensions
### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22 ### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22
#### Features: #### Features:

View File

@ -50,7 +50,7 @@ int test_vec4_ctor()
} }
#endif #endif
#if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A.xyzw; glm::vec4 B = A.xyzw;
@ -79,7 +79,7 @@ int test_vec4_ctor()
Error += glm::all(glm::equal(A, L)) ? 0 : 1; Error += glm::all(glm::equal(A, L)) ? 0 : 1;
Error += glm::all(glm::equal(A, M)) ? 0 : 1; Error += glm::all(glm::equal(A, M)) ? 0 : 1;
} }
#endif// GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec4 A(1); glm::vec4 A(1);

View File

@ -1291,8 +1291,10 @@ namespace ldexp_
static int test_constexpr() static int test_constexpr()
{ {
#if GLM_HAS_CONSTEXPR_CXX11
static_assert(glm::abs(1.0f) > 0.0f, "GLM: Failed constexpr"); static_assert(glm::abs(1.0f) > 0.0f, "GLM: Failed constexpr");
static_assert(glm::abs(glm::vec3(1.0f)) != glm::vec3(0.0f), "GLM: Failed constexpr"); static_assert(glm::abs(glm::vec3(1.0f)) != glm::vec3(0.0f), "GLM: Failed constexpr");
#endif // GLM_HAS_CONSTEXPR_CXX11
return 0; return 0;
} }

View File

@ -4,16 +4,18 @@
#if !GLM_HAS_ONLY_XYZW #if !GLM_HAS_ONLY_XYZW
int test_ivec2_swizzle() static int test_ivec2_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
glm::ivec2 A(1, 2); glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx(); glm::ivec2 B = A.yx();
glm::ivec2 C = B.yx(); glm::ivec2 C = B.yx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
return Error; return Error;
} }
@ -22,12 +24,14 @@ int test_ivec3_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
glm::ivec3 A(1, 2, 3); glm::ivec3 A(1, 2, 3);
glm::ivec3 B = A.zyx(); glm::ivec3 B = A.zyx();
glm::ivec3 C = B.zyx(); glm::ivec3 C = B.zyx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
return Error; return Error;
} }
@ -36,12 +40,14 @@ int test_ivec4_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
glm::ivec4 A(1, 2, 3, 4); glm::ivec4 A(1, 2, 3, 4);
glm::ivec4 B = A.wzyx(); glm::ivec4 B = A.wzyx();
glm::ivec4 C = B.wzyx(); glm::ivec4 C = B.wzyx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
return Error; return Error;
} }
@ -50,6 +56,7 @@ int test_vec4_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
glm::vec4 A(1, 2, 3, 4); glm::vec4 A(1, 2, 3, 4);
glm::vec4 B = A.wzyx(); glm::vec4 B = A.wzyx();
glm::vec4 C = B.wzyx(); glm::vec4 C = B.wzyx();
@ -59,6 +66,7 @@ int test_vec4_swizzle()
float f = glm::dot(C.wzyx(), C.xyzw()); float f = glm::dot(C.wzyx(), C.xyzw());
Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1; Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
return Error; return Error;
} }

View File

@ -1,57 +1,38 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#if GLM_HAS_ALIGNOF
# include <type_traits>
#endif
int test_aligned() int test_aligned()
{ {
int Error = 0; int Error = 0;
size_t size1_aligned = sizeof(glm::detail::storage<int, 1, true>::type); GLM_STATIC_ASSERT(sizeof(glm::vec4) == 4 * sizeof(float), "Invalid sizeof");
Error += size1_aligned == 1 ? 0 : 1;
size_t size2_aligned = sizeof(glm::detail::storage<int, 2, true>::type); size_t size1_aligned = sizeof(glm::detail::storage<1, int, true>::type);
Error += size2_aligned == 2 ? 0 : 1; Error += size1_aligned == sizeof(int) * 1 ? 0 : 1;
size_t size4_aligned = sizeof(glm::detail::storage<int, 4, true>::type); size_t size2_aligned = sizeof(glm::detail::storage<2, int, true>::type);
Error += size4_aligned == 4 ? 0 : 1; Error += size2_aligned == sizeof(int) * 2 ? 0 : 1;
size_t size8_aligned = sizeof(glm::detail::storage<int, 8, true>::type); size_t size4_aligned = sizeof(glm::detail::storage<4, int, true>::type);
Error += size8_aligned == 8 ? 0 : 1; Error += size4_aligned == sizeof(int) * 4 ? 0 : 1;
size_t size16_aligned = sizeof(glm::detail::storage<int, 16, true>::type);
Error += size16_aligned == 16 ? 0 : 1;
size_t size32_aligned = sizeof(glm::detail::storage<int, 32, true>::type);
Error += size32_aligned == 32 ? 0 : 1;
size_t size64_aligned = sizeof(glm::detail::storage<int, 64, true>::type);
Error += size64_aligned == 64 ? 0 : 1;
# if GLM_HAS_ALIGNOF # if GLM_HAS_ALIGNOF
size_t align1_aligned = alignof(glm::detail::storage<int, 1, true>::type); size_t align1_aligned = alignof(glm::detail::storage<1, int, true>::type);
Error += align1_aligned == 1 ? 0 : 1; Error += align1_aligned == 4 ? 0 : 1;
size_t align2_aligned = alignof(glm::detail::storage<int, 2, true>::type); size_t align2_aligned = alignof(glm::detail::storage<2, int, true>::type);
Error += align2_aligned == 2 ? 0 : 1; Error += align2_aligned == 8 ? 0 : 1;
size_t align4_aligned = alignof(glm::detail::storage<int, 4, true>::type); size_t align4_aligned = alignof(glm::detail::storage<4, int, true>::type);
Error += align4_aligned == 4 ? 0 : 1; Error += align4_aligned == 16 ? 0 : 1;
size_t align8_aligned = alignof(glm::detail::storage<int, 8, true>::type);
Error += align8_aligned == 8 ? 0 : 1;
size_t align16_aligned = alignof(glm::detail::storage<int, 16, true>::type);
Error += align16_aligned == 16 ? 0 : 1;
size_t align32_aligned = alignof(glm::detail::storage<int, 32, true>::type);
Error += align32_aligned == 32 ? 0 : 1;
size_t align64_aligned = alignof(glm::detail::storage<int, 64, true>::type);
Error += align64_aligned == 64 ? 0 : 1;
# elif GLM_COMPILER & GLM_COMPILER_GCC # elif GLM_COMPILER & GLM_COMPILER_GCC
size_t align1_aligned = __alignof__(glm::detail::storage<int, 1, true>::type); size_t align1_aligned = __alignof__(glm::detail::storage<1, int, true>::type);
Error += align1_aligned == 1 ? 0 : 1; Error += align1_aligned == 4 ? 0 : 1;
size_t align2_aligned = __alignof__(glm::detail::storage<int, 2, true>::type); size_t align2_aligned = __alignof__(glm::detail::storage<2, int, true>::type);
Error += align2_aligned == 2 ? 0 : 1; Error += align2_aligned == 8 ? 0 : 1;
size_t align4_aligned = __alignof__(glm::detail::storage<int, 4, true>::type); size_t align8_aligned = __alignof__(glm::detail::storage<4, int, true>::type);
Error += align4_aligned == 4 ? 0 : 1; Error += align8_aligned == 16 ? 0 : 1;
size_t align8_aligned = __alignof__(glm::detail::storage<int, 8, true>::type);
Error += align8_aligned == 8 ? 0 : 1;
size_t align16_aligned = __alignof__(glm::detail::storage<int, 16, true>::type);
Error += align16_aligned == 16 ? 0 : 1;
size_t align32_aligned = __alignof__(glm::detail::storage<int, 32, true>::type);
Error += align32_aligned == 32 ? 0 : 1;
size_t align64_aligned = __alignof__(glm::detail::storage<int, 64, true>::type);
Error += align64_aligned == 64 ? 0 : 1;
# endif //GLM_HAS_ALIGNOF # endif //GLM_HAS_ALIGNOF
@ -62,61 +43,33 @@ int test_unaligned()
{ {
int Error = 0; int Error = 0;
size_t size1_unaligned = sizeof(glm::detail::storage<int, 1, false>::type);
Error += size1_unaligned == 1 ? 0 : 1;
size_t size2_unaligned = sizeof(glm::detail::storage<int, 2, false>::type);
Error += size2_unaligned == 2 ? 0 : 1;
size_t size4_unaligned = sizeof(glm::detail::storage<int, 4, false>::type);
Error += size4_unaligned == 4 ? 0 : 1;
size_t size8_unaligned = sizeof(glm::detail::storage<int, 8, false>::type);
Error += size8_unaligned == 8 ? 0 : 1;
size_t size16_unaligned = sizeof(glm::detail::storage<int, 16, false>::type);
Error += size16_unaligned == 16 ? 0 : 1;
size_t size32_unaligned = sizeof(glm::detail::storage<int, 32, false>::type);
Error += size32_unaligned == 32 ? 0 : 1;
size_t size64_unaligned = sizeof(glm::detail::storage<int, 64, false>::type);
Error += size64_unaligned == 64 ? 0 : 1;
# if GLM_HAS_ALIGNOF # if GLM_HAS_ALIGNOF
size_t align1_unaligned = alignof(glm::detail::storage<int, 1, false>::type); size_t align1_unaligned = alignof(glm::detail::storage<1, int, false>::type);
Error += align1_unaligned == 1 ? 0 : 1; Error += align1_unaligned == sizeof(int) ? 0 : 1;
size_t align2_unaligned = alignof(glm::detail::storage<int, 2, false>::type); size_t align2_unaligned = alignof(glm::detail::storage<2, int, false>::type);
Error += align2_unaligned == 1 ? 0 : 1; Error += align2_unaligned == sizeof(int) ? 0 : 1;
size_t align4_unaligned = alignof(glm::detail::storage<int, 4, false>::type); size_t align3_unaligned = alignof(glm::detail::storage<3, int, false>::type);
Error += align4_unaligned == 1 ? 0 : 1; Error += align3_unaligned == sizeof(int) ? 0 : 1;
size_t align8_unaligned = alignof(glm::detail::storage<int, 8, false>::type); size_t align4_unaligned = alignof(glm::detail::storage<4, int, false>::type);
Error += align8_unaligned == 1 ? 0 : 1; Error += align4_unaligned == sizeof(int) ? 0 : 1;
size_t align16_unaligned = alignof(glm::detail::storage<int, 16, false>::type);
Error += align16_unaligned == 1 ? 0 : 1;
size_t align32_unaligned = alignof(glm::detail::storage<int, 32, false>::type);
Error += align32_unaligned == 1 ? 0 : 1;
size_t align64_unaligned = alignof(glm::detail::storage<int, 64, false>::type);
Error += align64_unaligned == 1 ? 0 : 1;
# elif GLM_COMPILER & GLM_COMPILER_GCC # elif GLM_COMPILER & GLM_COMPILER_GCC
size_t align1_unaligned = __alignof__(glm::detail::storage<int, 1, false>::type); size_t align1_unaligned = __alignof__(glm::detail::storage<1, int, false>::type);
Error += align1_unaligned == 1 ? 0 : 1; Error += align1_unaligned == sizeof(int) ? 0 : 1;
size_t align2_unaligned = __alignof__(glm::detail::storage<int, 2, false>::type); size_t align2_unaligned = __alignof__(glm::detail::storage<2, int, false>::type);
Error += align2_unaligned == 1 ? 0 : 1; Error += align2_unaligned == sizeof(int) ? 0 : 1;
size_t align4_unaligned = __alignof__(glm::detail::storage<int, 4, false>::type); size_t align4_unaligned = __alignof__(glm::detail::storage<3, int, false>::type);
Error += align4_unaligned == 1 ? 0 : 1; Error += align4_unaligned == sizeof(int) ? 0 : 1;
size_t align8_unaligned = __alignof__(glm::detail::storage<int, 8, false>::type); size_t align8_unaligned = __alignof__(glm::detail::storage<4, int, false>::type);
Error += align8_unaligned == 1 ? 0 : 1; Error += align8_unaligned == sizeof(int) ? 0 : 1;
size_t align16_unaligned = __alignof__(glm::detail::storage<int, 16, false>::type);
Error += align16_unaligned == 1 ? 0 : 1;
size_t align32_unaligned = __alignof__(glm::detail::storage<int, 32, false>::type);
Error += align32_unaligned == 1 ? 0 : 1;
size_t align64_unaligned = __alignof__(glm::detail::storage<int, 64, false>::type);
Error += align64_unaligned == 1 ? 0 : 1;
# endif //GLM_HAS_ALIGNOF # endif //GLM_HAS_ALIGNOF
return Error; return Error;
} }
int main() int main()
{ {
int Error = 0; int Error = 0;

View File

@ -180,7 +180,7 @@ int test_inverse()
int test_ctr() int test_ctr()
{ {
int Error(0); int Error = 0;
#if GLM_HAS_TRIVIAL_QUERIES #if GLM_HAS_TRIVIAL_QUERIES
//Error += std::is_trivially_default_constructible<glm::mat4>::value ? 0 : 1; //Error += std::is_trivially_default_constructible<glm::mat4>::value ? 0 : 1;
@ -190,7 +190,7 @@ int test_ctr()
//Error += std::has_trivial_copy_constructor<glm::mat4>::value ? 0 : 1; //Error += std::has_trivial_copy_constructor<glm::mat4>::value ? 0 : 1;
#endif #endif
#if(GLM_HAS_INITIALIZER_LISTS) #if GLM_HAS_INITIALIZER_LISTS
glm::mat4 m0( glm::mat4 m0(
glm::vec4(0, 1, 2, 3), glm::vec4(0, 1, 2, 3),
glm::vec4(4, 5, 6, 7), glm::vec4(4, 5, 6, 7),

View File

@ -69,7 +69,7 @@ int test_vec1_ctor()
} }
#endif #endif
*/ */
#if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec2 A = glm::vec2(1.0f, 2.0f); glm::vec2 A = glm::vec2(1.0f, 2.0f);
glm::vec2 B = A.xy; glm::vec2 B = A.xy;
@ -80,7 +80,7 @@ int test_vec1_ctor()
Error += glm::all(glm::equal(A, C)) ? 0 : 1; Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1; Error += glm::all(glm::equal(A, D)) ? 0 : 1;
} }
#endif//GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec2 A = glm::vec2(2.0f); glm::vec2 A = glm::vec2(2.0f);

View File

@ -236,7 +236,7 @@ static int test_ctor()
} }
#endif #endif
#if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec2 A = glm::vec2(1.0f, 2.0f); glm::vec2 A = glm::vec2(1.0f, 2.0f);
glm::vec2 B = A.xy; glm::vec2 B = A.xy;
@ -247,7 +247,7 @@ static int test_ctor()
Error += glm::all(glm::equal(A, C)) ? 0 : 1; Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1; Error += glm::all(glm::equal(A, D)) ? 0 : 1;
} }
#endif//GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec2 A = glm::vec2(2.0f); glm::vec2 A = glm::vec2(2.0f);

View File

@ -45,7 +45,7 @@ int test_vec3_ctor()
} }
#endif #endif
#if(GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE)) #if(GLM_LANG & GLM_LANG_CXXMS_FLAG && defined(GLM_FORCE_SWIZZLE))
{ {
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f); glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
glm::vec3 B = A.xyz; glm::vec3 B = A.xyz;
@ -64,7 +64,7 @@ int test_vec3_ctor()
Error += glm::all(glm::equal(A, G)) ? 0 : 1; Error += glm::all(glm::equal(A, G)) ? 0 : 1;
Error += glm::all(glm::equal(A, H)) ? 0 : 1; Error += glm::all(glm::equal(A, H)) ? 0 : 1;
} }
#endif//(GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE)) #endif//(GLM_LANG & GLM_LANG_CXXMS_FLAG && defined(GLM_FORCE_SWIZZLE))
{ {
glm::vec3 A(1); glm::vec3 A(1);
@ -469,6 +469,8 @@ int test_vec3_swizzle_functions()
{ {
int Error = 0; int Error = 0;
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
// NOTE: template functions cannot pick up the implicit conversion from // NOTE: template functions cannot pick up the implicit conversion from
// a swizzle to the unswizzled type, therefore the operator() must be // a swizzle to the unswizzled type, therefore the operator() must be
// used. E.g.: // used. E.g.:
@ -501,6 +503,8 @@ int test_vec3_swizzle_functions()
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1; r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1; r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
return Error; return Error;
} }

View File

@ -74,7 +74,7 @@ static int test_vec4_ctor()
} }
#endif #endif
#if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A.xyzw; glm::vec4 B = A.xyzw;
@ -103,7 +103,7 @@ static int test_vec4_ctor()
Error += glm::all(glm::equal(A, L)) ? 0 : 1; Error += glm::all(glm::equal(A, L)) ? 0 : 1;
Error += glm::all(glm::equal(A, M)) ? 0 : 1; Error += glm::all(glm::equal(A, M)) ? 0 : 1;
} }
#endif// GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) #endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
{ {
glm::vec4 A(1); glm::vec4 A(1);