Improved aligned types support

This commit is contained in:
Christophe Riccio 2016-07-17 03:06:58 +02:00
parent eb20cdc6ae
commit b3d57f2cc9
8 changed files with 42 additions and 10 deletions

View File

@ -647,6 +647,10 @@
# define GLM_EXPLICIT # define GLM_EXPLICIT
#endif #endif
///////////////////////////////////////////////////////////////////////////////////
#define GLM_HAS_ALIGNED_TYPE GLM_HAS_UNRESTRICTED_UNIONS
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Length type // Length type

View File

@ -16,7 +16,7 @@ namespace detail
uint8 data[size]; uint8 data[size];
} type; } type;
}; };
/*
template <typename T, std::size_t size> template <typename T, std::size_t size>
struct storage<T, size, true> struct storage<T, size, true>
{ {
@ -24,7 +24,7 @@ namespace detail
uint8 data[size]; uint8 data[size];
} type; } type;
}; };
*/
# if GLM_ARCH & GLM_ARCH_SSE2_BIT # if GLM_ARCH & GLM_ARCH_SSE2_BIT
template <> template <>
struct storage<float, 16, true> struct storage<float, 16, true>
@ -43,6 +43,31 @@ namespace detail
{ {
typedef glm_uvec4 type; typedef glm_uvec4 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 <>
struct storage<int, 16, true>
{
typedef glm_128 type;
};
template <>
struct storage<unsigned int, 16, true>
{
typedef glm_128 type;
};
*/
# endif # endif
# if (GLM_ARCH & GLM_ARCH_AVX_BIT) # if (GLM_ARCH & GLM_ARCH_AVX_BIT)

View File

@ -27,7 +27,7 @@ namespace glm
// -- Data -- // -- 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 # if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wpedantic"

View File

@ -26,7 +26,7 @@ namespace glm
// -- Data -- // -- 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 # if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wpedantic"

View File

@ -26,7 +26,7 @@ namespace glm
// -- Data -- // -- 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 # if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wpedantic"

View File

@ -27,7 +27,7 @@ namespace glm
// -- Data -- // -- 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 # if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wpedantic"

View File

@ -40,7 +40,7 @@ namespace glm
// -- Data -- // -- 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 # if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wpedantic"

View File

@ -21,7 +21,9 @@ struct my_vec4_aligned
glm::uint32 a; glm::uint32 a;
glm::aligned_vec4 b; glm::aligned_vec4 b;
}; };
GLM_STATIC_ASSERT(sizeof(my_vec4_aligned) == sizeof(glm::aligned_vec4) * 2, "glm::vec4 aligned is not correct"); #if GLM_HAS_ALIGNED_TYPE
GLM_STATIC_ASSERT(sizeof(my_vec4_aligned) == sizeof(glm::aligned_vec4) * 2, "glm::vec4 aligned is not correct");
#endif
struct my_dvec4_packed struct my_dvec4_packed
{ {
@ -35,7 +37,6 @@ struct my_dvec4_aligned
glm::uint64 a; glm::uint64 a;
glm::aligned_dvec4 b; glm::aligned_dvec4 b;
}; };
//FIXME
//GLM_STATIC_ASSERT(sizeof(my_dvec4_aligned) == sizeof(glm::aligned_dvec4) * 2, "glm::dvec4 aligned is not correct"); //GLM_STATIC_ASSERT(sizeof(my_dvec4_aligned) == sizeof(glm::aligned_dvec4) * 2, "glm::dvec4 aligned is not correct");
struct my_ivec4_packed struct my_ivec4_packed
@ -50,7 +51,9 @@ struct my_ivec4_aligned
glm::uint32 a; glm::uint32 a;
glm::aligned_ivec4 b; glm::aligned_ivec4 b;
}; };
GLM_STATIC_ASSERT(sizeof(my_ivec4_aligned) == sizeof(glm::aligned_ivec4) * 2, "glm::ivec4 aligned is not correct"); #if GLM_HAS_ALIGNED_TYPE
GLM_STATIC_ASSERT(sizeof(my_ivec4_aligned) == sizeof(glm::aligned_ivec4) * 2, "glm::ivec4 aligned is not correct");
#endif
struct my_u8vec4_packed struct my_u8vec4_packed
{ {