Browse Source

More tests and comments for type_aligned

Christophe Riccio 11 years ago
parent
commit
c79394b899
2 changed files with 305 additions and 214 deletions
  1. 212 212
      glm/gtc/type_aligned.hpp
  2. 93 2
      test/gtc/gtc_type_aligned.cpp

File diff suppressed because it is too large
+ 212 - 212
glm/gtc/type_aligned.hpp


+ 93 - 2
test/gtc/gtc_type_aligned.cpp

@@ -8,12 +8,103 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #include <glm/gtc/type_aligned.hpp>
+#include <cstdio>
+
+typedef __declspec(align(1)) glm::vec3 unaligned_vec3;
 
 int test_decl()
 {
-	
+	int Error(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];
+		};
 
-	return 0;
+		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()

Some files were not shown because too many files changed in this diff