Improved aligned types support

This commit is contained in:
Christophe Riccio 2016-07-17 03:37:24 +02:00
parent ad1ae45066
commit 8c8c8367e3
4 changed files with 61 additions and 30 deletions

View File

@ -7,18 +7,23 @@ namespace glm
{ {
enum precision enum precision
{ {
aligned_highp,
aligned_mediump,
aligned_lowp,
packed_highp, packed_highp,
packed_mediump, packed_mediump,
packed_lowp, packed_lowp,
aligned = aligned_highp,
packed = packed_highp, # if GLM_HAS_ALIGNED_TYPE
aligned_highp,
aligned_mediump,
aligned_lowp,
aligned = aligned_highp,
# endif
highp = packed_highp, highp = packed_highp,
mediump = packed_mediump, mediump = packed_mediump,
lowp = packed_lowp, lowp = packed_lowp,
# ifdef GLM_FORCE_ALIGNED packed = packed_highp,
# if GLM_HAS_ALIGNED_TYPE && defined(GLM_FORCE_ALIGNED)
defaultp = aligned_highp defaultp = aligned_highp
# else # else
defaultp = highp defaultp = highp
@ -33,22 +38,24 @@ namespace detail
static const bool value = false; static const bool value = false;
}; };
template<> # if GLM_HAS_ALIGNED_TYPE
struct is_aligned<glm::aligned_lowp> template<>
{ struct is_aligned<glm::aligned_lowp>
static const bool value = true; {
}; static const bool value = true;
};
template<> template<>
struct is_aligned<glm::aligned_mediump> struct is_aligned<glm::aligned_mediump>
{ {
static const bool value = true; static const bool value = true;
}; };
template<> template<>
struct is_aligned<glm::aligned_highp> struct is_aligned<glm::aligned_highp>
{ {
static const bool value = true; static const bool value = true;
}; };
# endif
}//namespace detail }//namespace detail
}//namespace glm }//namespace glm

View File

@ -50,6 +50,9 @@
#include "./gtc/type_ptr.hpp" #include "./gtc/type_ptr.hpp"
#include "./gtc/ulp.hpp" #include "./gtc/ulp.hpp"
#include "./gtc/vec1.hpp" #include "./gtc/vec1.hpp"
#if GLM_HAS_ALIGNED_TYPE
# include "./gtc/type_aligned.hpp"
#endif
#include "./gtx/associated_min_max.hpp" #include "./gtx/associated_min_max.hpp"
#include "./gtx/bit.hpp" #include "./gtx/bit.hpp"
@ -95,7 +98,6 @@
#endif #endif
#include "./gtx/transform.hpp" #include "./gtx/transform.hpp"
#include "./gtx/transform2.hpp" #include "./gtx/transform2.hpp"
#include "./gtx/type_aligned.hpp"
#include "./gtx/vector_angle.hpp" #include "./gtx/vector_angle.hpp"
#include "./gtx/vector_query.hpp" #include "./gtx/vector_query.hpp"
#include "./gtx/wrap.hpp" #include "./gtx/wrap.hpp"

View File

@ -1,5 +1,21 @@
/// @ref gtc_type_aligned /// @ref gtc_type_aligned
/// @file glm/gtc/type_aligned.hpp /// @file glm/gtc/type_aligned.hpp
///
/// @see core (dependence)
///
/// @defgroup gtc_type_aligned GLM_GTC_type_aligned
/// @ingroup gtc
///
/// @brief Aligned types.
/// <glm/gtc/type_aligned.hpp> 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 #pragma once

View File

@ -1,5 +1,7 @@
#define GLM_MESSAGES #define GLM_MESSAGES
#define GLM_FORCE_ALIGNED #include <glm/glm.hpp>
#if GLM_HAS_ALIGNED_TYPE
#include <glm/gtc/type_aligned.hpp> #include <glm/gtc/type_aligned.hpp>
GLM_STATIC_ASSERT(glm::detail::is_aligned<glm::aligned_lowp>::value, "aligned_lowp is not aligned"); GLM_STATIC_ASSERT(glm::detail::is_aligned<glm::aligned_lowp>::value, "aligned_lowp is not aligned");
@ -21,9 +23,7 @@ struct my_vec4_aligned
glm::uint32 a; glm::uint32 a;
glm::aligned_vec4 b; glm::aligned_vec4 b;
}; };
#if GLM_HAS_ALIGNED_TYPE GLM_STATIC_ASSERT(sizeof(my_vec4_aligned) == sizeof(glm::aligned_vec4) * 2, "glm::vec4 aligned is not correct");
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
{ {
@ -51,9 +51,7 @@ struct my_ivec4_aligned
glm::uint32 a; glm::uint32 a;
glm::aligned_ivec4 b; glm::aligned_ivec4 b;
}; };
#if GLM_HAS_ALIGNED_TYPE GLM_STATIC_ASSERT(sizeof(my_ivec4_aligned) == sizeof(glm::aligned_ivec4) * 2, "glm::ivec4 aligned is not correct");
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
{ {
@ -92,7 +90,6 @@ int test_copy()
return Error; return Error;
} }
int main() int main()
{ {
int Error = 0; int Error = 0;
@ -110,3 +107,12 @@ int main()
return Error; return Error;
} }
#else
int main()
{
return 0;
}
#endif//GLM_HAS_ALIGNED_TYPE