More tests and comments for type_aligned
This commit is contained in:
parent
9b96b31f0e
commit
c79394b899
File diff suppressed because it is too large
Load Diff
@ -8,12 +8,103 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <glm/gtc/type_aligned.hpp>
|
#include <glm/gtc/type_aligned.hpp>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
typedef __declspec(align(1)) glm::vec3 unaligned_vec3;
|
||||||
|
|
||||||
int test_decl()
|
int test_decl()
|
||||||
{
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
return 0;
|
{
|
||||||
|
struct S1
|
||||||
|
{
|
||||||
|
glm::aligned_vec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S2
|
||||||
|
{
|
||||||
|
glm::vec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
|
||||||
|
|
||||||
|
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct S1
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::vec3 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S2
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::aligned_vec3 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S3
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
unaligned_vec3 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S4
|
||||||
|
{
|
||||||
|
short B;
|
||||||
|
bool A;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S5
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
float B[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("vec3: %d, aligned: %d, unaligned: %d, bool: %d, array: %d\n", sizeof(S1), sizeof(S2), sizeof(S3), sizeof(S4), sizeof(S5));
|
||||||
|
|
||||||
|
Error += sizeof(S1) <= sizeof(S2) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct S1
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::aligned_vec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S2
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::vec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
|
||||||
|
|
||||||
|
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct S1
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::aligned_dvec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct S2
|
||||||
|
{
|
||||||
|
bool A;
|
||||||
|
glm::dvec4 B;
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("dvec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
|
||||||
|
|
||||||
|
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user