• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// @ref gtx_simd_mat4
2 /// @file glm/gtx/simd_mat4.hpp
3 ///
4 /// @see core (dependence)
5 ///
6 /// @defgroup gtx_simd_mat4 GLM_GTX_simd_mat4
7 /// @ingroup gtx
8 ///
9 /// @brief SIMD implementation of mat4 type.
10 ///
11 /// <glm/gtx/simd_mat4.hpp> need to be included to use these functionalities.
12 
13 #pragma once
14 
15 // Dependencies
16 #include "../detail/setup.hpp"
17 
18 #if(GLM_ARCH != GLM_ARCH_PURE)
19 
20 #if(GLM_ARCH & GLM_ARCH_SSE2_BIT)
21 #	include "../detail/intrinsic_matrix.hpp"
22 #	include "../gtx/simd_vec4.hpp"
23 #else
24 #	error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics"
25 #endif
26 
27 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
28 #	pragma message("GLM: GLM_GTX_simd_mat4 extension included")
29 #	pragma message("GLM: GLM_GTX_simd_mat4 extension is deprecated and will be removed in GLM 0.9.9. Use mat4 instead and use compiler SIMD arguments.")
30 #endif
31 
32 namespace glm{
33 namespace detail
34 {
35 	/// 4x4 Matrix implemented using SIMD SEE intrinsics.
36 	/// \ingroup gtx_simd_mat4
37 	GLM_ALIGNED_STRUCT(16) fmat4x4SIMD
38 	{
39 		typedef float value_type;
40 		typedef fvec4SIMD col_type;
41 		typedef fvec4SIMD row_type;
42 		typedef std::size_t size_type;
43 		typedef fmat4x4SIMD type;
44 		typedef fmat4x4SIMD transpose_type;
45 
46 		typedef tmat4x4<float, defaultp> pure_type;
47 		typedef tvec4<float, defaultp> pure_row_type;
48 		typedef tvec4<float, defaultp> pure_col_type;
49 		typedef tmat4x4<float, defaultp> pure_transpose_type;
50 
51 		GLM_FUNC_DECL length_t length() const;
52 
53 		fvec4SIMD Data[4];
54 
55 		//////////////////////////////////////
56 		// Constructors
57 
58 		fmat4x4SIMD() GLM_DEFAULT_CTOR;
59 		explicit fmat4x4SIMD(float const & s);
60 		explicit fmat4x4SIMD(
61 			float const & x0, float const & y0, float const & z0, float const & w0,
62 			float const & x1, float const & y1, float const & z1, float const & w1,
63 			float const & x2, float const & y2, float const & z2, float const & w2,
64 			float const & x3, float const & y3, float const & z3, float const & w3);
65 		explicit fmat4x4SIMD(
66 			fvec4SIMD const & v0,
67 			fvec4SIMD const & v1,
68 			fvec4SIMD const & v2,
69 			fvec4SIMD const & v3);
70 		explicit fmat4x4SIMD(
71 			mat4x4 const & m);
72 		explicit fmat4x4SIMD(
73 			__m128 const in[4]);
74 
75 		// Conversions
76 		//template <typename U>
77 		//explicit tmat4x4(tmat4x4<U> const & m);
78 
79 		//explicit tmat4x4(tmat2x2<T> const & x);
80 		//explicit tmat4x4(tmat3x3<T> const & x);
81 		//explicit tmat4x4(tmat2x3<T> const & x);
82 		//explicit tmat4x4(tmat3x2<T> const & x);
83 		//explicit tmat4x4(tmat2x4<T> const & x);
84 		//explicit tmat4x4(tmat4x2<T> const & x);
85 		//explicit tmat4x4(tmat3x4<T> const & x);
86 		//explicit tmat4x4(tmat4x3<T> const & x);
87 
88 		// Accesses
89 		fvec4SIMD & operator[](length_t i);
90 		fvec4SIMD const & operator[](length_t i) const;
91 
92 		// Unary updatable operators
93 		fmat4x4SIMD & operator= (fmat4x4SIMD const & m) GLM_DEFAULT;
94 		fmat4x4SIMD & operator+= (float const & s);
95 		fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
96 		fmat4x4SIMD & operator-= (float const & s);
97 		fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
98 		fmat4x4SIMD & operator*= (float const & s);
99 		fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
100 		fmat4x4SIMD & operator/= (float const & s);
101 		fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
102 		fmat4x4SIMD & operator++ ();
103 		fmat4x4SIMD & operator-- ();
104 	};
105 
106 	// Binary operators
107 	fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
108 	fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
109 	fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
110 
111 	fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
112 	fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
113 	fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
114 
115 	fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
116 	fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
117 
118 	fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
119 	fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
120 
121 	fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
122 
123 	fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
124 	fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
125 
126 	fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
127 	fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
128 
129 	fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
130 
131 	// Unary constant operators
132 	fmat4x4SIMD const operator-  (fmat4x4SIMD const & m);
133 	fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
134 	fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
135 }//namespace detail
136 
137 	typedef detail::fmat4x4SIMD simdMat4;
138 
139 	/// @addtogroup gtx_simd_mat4
140 	/// @{
141 
142 	//! Convert a simdMat4 to a mat4.
143 	//! (From GLM_GTX_simd_mat4 extension)
144 	mat4 mat4_cast(
145 		detail::fmat4x4SIMD const & x);
146 
147 	//! Multiply matrix x by matrix y component-wise, i.e.,
148 	//! result[i][j] is the scalar product of x[i][j] and y[i][j].
149 	//! (From GLM_GTX_simd_mat4 extension).
150 	detail::fmat4x4SIMD matrixCompMult(
151 		detail::fmat4x4SIMD const & x,
152 		detail::fmat4x4SIMD const & y);
153 
154 	//! Treats the first parameter c as a column vector
155 	//! and the second parameter r as a row vector
156 	//! and does a linear algebraic matrix multiply c * r.
157 	//! (From GLM_GTX_simd_mat4 extension).
158 	detail::fmat4x4SIMD outerProduct(
159 		detail::fvec4SIMD const & c,
160 		detail::fvec4SIMD const & r);
161 
162 	//! Returns the transposed matrix of x
163 	//! (From GLM_GTX_simd_mat4 extension).
164 	detail::fmat4x4SIMD transpose(
165 		detail::fmat4x4SIMD const & x);
166 
167 	//! Return the determinant of a mat4 matrix.
168 	//! (From GLM_GTX_simd_mat4 extension).
169 	float determinant(
170 		detail::fmat4x4SIMD const & m);
171 
172 	//! Return the inverse of a mat4 matrix.
173 	//! (From GLM_GTX_simd_mat4 extension).
174 	detail::fmat4x4SIMD inverse(
175 		detail::fmat4x4SIMD const & m);
176 
177 	/// @}
178 }// namespace glm
179 
180 #include "simd_mat4.inl"
181 
182 #endif//(GLM_ARCH != GLM_ARCH_PURE)
183