This commit is contained in:
Christophe Riccio 2016-06-02 01:01:36 +02:00
parent fd4ada5843
commit 5fdca07eee
3 changed files with 40 additions and 9 deletions

View File

@ -10,7 +10,7 @@ namespace glm{
namespace detail
{
template <typename T, std::size_t size, bool aligned>
struct simd_data
struct storage
{
typedef struct type {
uint8 data[size];
@ -18,7 +18,7 @@ namespace detail
};
template <typename T, std::size_t size>
struct simd_data<T, size, true>
struct storage<T, size, true>
{
typedef GLM_ALIGNED_STRUCT(size) type {
uint8 data[size];
@ -27,19 +27,19 @@ namespace detail
# if GLM_ARCH & GLM_ARCH_SSE2_BIT
template <>
struct simd_data<float, 16, true>
struct storage<float, 16, true>
{
typedef glm_vec4 type;
};
template <>
struct simd_data<int, 16, true>
struct storage<int, 16, true>
{
typedef glm_ivec4 type;
};
template <>
struct simd_data<unsigned int, 16, true>
struct storage<unsigned int, 16, true>
{
typedef glm_uvec4 type;
};
@ -47,7 +47,7 @@ namespace detail
# if (GLM_ARCH & GLM_ARCH_AVX_BIT)
template <>
struct simd_data<double, 32, true>
struct storage<double, 32, true>
{
typedef glm_dvec4 type;
};
@ -55,13 +55,13 @@ namespace detail
# if (GLM_ARCH & GLM_ARCH_AVX2_BIT)
template <>
struct simd_data<int64, 32, true>
struct storage<int64, 32, true>
{
typedef glm_i64vec4 type;
};
template <>
struct simd_data<uint64, 32, true>
struct storage<uint64, 32, true>
{
typedef glm_u64vec4 type;
};

View File

@ -34,7 +34,7 @@ namespace glm
struct { T r, g, b, a; };
struct { T s, t, p, q; };
typename detail::simd_data<T, sizeof(T) * 4, detail::is_aligned<P>::value>::type data;
typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<P>::value>::type data;
# ifdef GLM_SWIZZLE
_GLM_SWIZZLE4_2_MEMBERS(T, P, glm::tvec2, x, y, z, w)

View File

@ -52,6 +52,37 @@ struct my_u8vec4_packed
};
GLM_STATIC_ASSERT(sizeof(my_u8vec4_packed) == sizeof(glm::uint32) + sizeof(glm::u8vec4), "glm::u8vec4 packed is not correct");
int test_copy()
{
int Error = 0;
{
glm::aligned_ivec4 const a(1);
glm::ivec4 const u(a);
Error += a.x == u.x ? 0 : 1;
Error += a.y == u.y ? 0 : 1;
Error += a.z == u.z ? 0 : 1;
Error += a.w == u.w ? 0 : 1;
}
{
my_ivec4_aligned a;
a.b = glm::ivec4(1);
my_ivec4_packed u;
u.b = glm::ivec4(1);
Error += a.b.x == u.b.x ? 0 : 1;
Error += a.b.y == u.b.y ? 0 : 1;
Error += a.b.z == u.b.z ? 0 : 1;
Error += a.b.w == u.b.w ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;