mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
merging master
This commit is contained in:
commit
84f4c6e0f9
@ -67,7 +67,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& N, tvec4<float, P> const& I, tvec4<float, P> const& Nref)
|
||||
{
|
||||
tvec4<float, P> result(uninitialize);
|
||||
result.data = glm_vec4_faceforward(N.data. I.data, Nref.data);
|
||||
result.data = glm_vec4_faceforward(N.data, I.data, Nref.data);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
@ -317,7 +317,7 @@ namespace detail
|
||||
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<int, P> bitCount(vecType<T, P> const & v)
|
||||
{
|
||||
#ifdef GLM_COMPILER_VC
|
||||
#if GLM_COMPILER & GLM_COMPILER_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4310) //cast truncates constant value
|
||||
#endif
|
||||
@ -329,7 +329,7 @@ namespace detail
|
||||
x = detail::compute_bitfieldBitCountStep<typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned<T>::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned<T>::type(16));
|
||||
x = detail::compute_bitfieldBitCountStep<typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned<T>::type(0x00000000FFFFFFFFull), typename detail::make_unsigned<T>::type(32));
|
||||
return vecType<int, P>(x);
|
||||
#ifdef GLM_COMPILER_VC
|
||||
#if GLM_COMPILER & GLM_COMPILER_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
@ -418,6 +418,19 @@
|
||||
((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA50))))
|
||||
#endif
|
||||
|
||||
// N2341 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
|
||||
#if GLM_COMPILER & GLM_COMPILER_CLANG
|
||||
# define GLM_HAS_ALIGNOF __has_feature(c_alignof)
|
||||
#elif GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
# define GLM_HAS_ALIGNOF 1
|
||||
#else
|
||||
# define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
|
||||
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
|
||||
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \
|
||||
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)) || \
|
||||
((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70))))
|
||||
#endif
|
||||
|
||||
//
|
||||
#if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
# define GLM_HAS_ASSIGNABLE 1
|
||||
|
@ -9,21 +9,6 @@
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
#ifdef GLM_COMPILER_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
|
||||
#endif
|
||||
template<std::size_t N> struct aligned {};
|
||||
template<> GLM_ALIGNED_STRUCT(1) aligned<1>{};
|
||||
template<> GLM_ALIGNED_STRUCT(2) aligned<2>{};
|
||||
template<> GLM_ALIGNED_STRUCT(4) aligned<4>{};
|
||||
template<> GLM_ALIGNED_STRUCT(8) aligned<8>{};
|
||||
template<> GLM_ALIGNED_STRUCT(16) aligned<16>{};
|
||||
template<> GLM_ALIGNED_STRUCT(32) aligned<32>{};
|
||||
template<> GLM_ALIGNED_STRUCT(64) aligned<64>{};
|
||||
#ifdef GLM_COMPILER_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
template <typename T, std::size_t size, bool aligned>
|
||||
struct storage
|
||||
{
|
||||
@ -32,15 +17,22 @@ namespace detail
|
||||
} type;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t size>
|
||||
struct storage<T, size, true>
|
||||
{
|
||||
struct type : aligned<size>
|
||||
{
|
||||
uint8 data[size];
|
||||
#define GLM_ALIGNED_STORAGE_TYPE_STRUCT(x) \
|
||||
template <typename T> \
|
||||
struct storage<T, x, true> { \
|
||||
GLM_ALIGNED_STRUCT(x) type { \
|
||||
uint8 data[x]; \
|
||||
}; \
|
||||
};
|
||||
};
|
||||
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(1)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(2)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(4)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(8)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(16)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(32)
|
||||
GLM_ALIGNED_STORAGE_TYPE_STRUCT(64)
|
||||
|
||||
# if GLM_ARCH & GLM_ARCH_SSE2_BIT
|
||||
template <>
|
||||
struct storage<float, 16, true>
|
||||
|
@ -101,7 +101,7 @@ namespace glm
|
||||
|
||||
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C, typename D>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(A a, B b, C c, D d);
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD tvec4(A a, B b, C c, D d);
|
||||
template <typename A, typename B, typename C, typename D>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, P> const& a, tvec1<B, P> const& b, tvec1<C, P> const& c, tvec1<D, P> const& d);
|
||||
|
||||
|
@ -196,7 +196,7 @@ namespace detail
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename A, typename B, typename C, typename D>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(A a, B b, C c, D d) :
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(A a, B b, C c, D d) :
|
||||
x(static_cast<T>(a)),
|
||||
y(static_cast<T>(b)),
|
||||
z(static_cast<T>(c)),
|
||||
|
@ -458,7 +458,7 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
|
||||
data(_mm_set_epi32(d, c, b, a))
|
||||
{}
|
||||
/*
|
||||
|
||||
template <>
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_lowp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
|
||||
@ -476,7 +476,6 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
|
||||
data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a)))
|
||||
{}
|
||||
*/
|
||||
}//namespace glm
|
||||
|
||||
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
|
||||
|
@ -71,6 +71,9 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
||||
#### [GLM 0.9.8.1](https://github.com/g-truc/glm/tree/0.9.8) - 2016-XX-XX
|
||||
##### Fixes:
|
||||
- Fixed GCC warning filtering, replaced -pedantic by -Wpedantic
|
||||
- Fixed SIMD faceforward bug. #549
|
||||
- Fixed GCC 4.8 with C++11 compilation option #550
|
||||
- Fixed Visual Studio aligned type W4 warning #548
|
||||
|
||||
#### [GLM 0.9.8.0](https://github.com/g-truc/glm/releases/tag/0.9.8.0) - 2016-09-11
|
||||
##### Features:
|
||||
|
@ -1,3 +1,4 @@
|
||||
glmCreateTestGTC(core_type_aligned)
|
||||
glmCreateTestGTC(core_type_cast)
|
||||
glmCreateTestGTC(core_type_ctor)
|
||||
glmCreateTestGTC(core_type_float)
|
||||
|
128
test/core/core_type_aligned.cpp
Normal file
128
test/core/core_type_aligned.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
int test_aligned()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
size_t size1_aligned = sizeof(glm::detail::storage<int, 1, true>::type);
|
||||
Error += size1_aligned == 1 ? 0 : 1;
|
||||
size_t size2_aligned = sizeof(glm::detail::storage<int, 2, true>::type);
|
||||
Error += size2_aligned == 2 ? 0 : 1;
|
||||
size_t size4_aligned = sizeof(glm::detail::storage<int, 4, true>::type);
|
||||
Error += size4_aligned == 4 ? 0 : 1;
|
||||
size_t size8_aligned = sizeof(glm::detail::storage<int, 8, true>::type);
|
||||
Error += size8_aligned == 8 ? 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
|
||||
|
||||
size_t align1_aligned = alignof(glm::detail::storage<int, 1, true>::type);
|
||||
Error += align1_aligned == 1 ? 0 : 1;
|
||||
size_t align2_aligned = alignof(glm::detail::storage<int, 2, true>::type);
|
||||
Error += align2_aligned == 2 ? 0 : 1;
|
||||
size_t align4_aligned = alignof(glm::detail::storage<int, 4, true>::type);
|
||||
Error += align4_aligned == 4 ? 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
|
||||
|
||||
size_t align1_aligned = __alignof__(glm::detail::storage<int, 1, true>::type);
|
||||
Error += align1_aligned == 1 ? 0 : 1;
|
||||
size_t align2_aligned = __alignof__(glm::detail::storage<int, 2, true>::type);
|
||||
Error += align2_aligned == 2 ? 0 : 1;
|
||||
size_t align4_aligned = __alignof__(glm::detail::storage<int, 4, true>::type);
|
||||
Error += align4_aligned == 4 ? 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
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_unaligned()
|
||||
{
|
||||
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
|
||||
|
||||
size_t align1_unaligned = alignof(glm::detail::storage<int, 1, false>::type);
|
||||
Error += align1_unaligned == 1 ? 0 : 1;
|
||||
size_t align2_unaligned = alignof(glm::detail::storage<int, 2, false>::type);
|
||||
Error += align2_unaligned == 1 ? 0 : 1;
|
||||
size_t align4_unaligned = alignof(glm::detail::storage<int, 4, false>::type);
|
||||
Error += align4_unaligned == 1 ? 0 : 1;
|
||||
size_t align8_unaligned = alignof(glm::detail::storage<int, 8, false>::type);
|
||||
Error += align8_unaligned == 1 ? 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;
|
||||
|
||||
# else
|
||||
|
||||
size_t align1_unaligned = __alignof__(glm::detail::storage<int, 1, false>::type);
|
||||
Error += align1_unaligned == 1 ? 0 : 1;
|
||||
size_t align2_unaligned = __alignof__(glm::detail::storage<int, 2, false>::type);
|
||||
Error += align2_unaligned == 1 ? 0 : 1;
|
||||
size_t align4_unaligned = __alignof__(glm::detail::storage<int, 4, false>::type);
|
||||
Error += align4_unaligned == 1 ? 0 : 1;
|
||||
size_t align8_unaligned = __alignof__(glm::detail::storage<int, 8, false>::type);
|
||||
Error += align8_unaligned == 1 ? 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
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_aligned();
|
||||
Error += test_unaligned();
|
||||
|
||||
return Error;
|
||||
}
|
Loading…
Reference in New Issue
Block a user