simd_mat4.hpp
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 #ifndef GLM_GTX_simd_mat4
39 #define GLM_GTX_simd_mat4 GLM_VERSION
40 
41 // Dependency:
42 #include "../glm.hpp"
43 
44 #if(GLM_ARCH != GLM_ARCH_PURE)
45 
46 #if(GLM_ARCH & GLM_ARCH_SSE2)
47 # include "../core/intrinsic_matrix.hpp"
48 # include "../gtx/simd_vec4.hpp"
49 #else
50 # error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics"
51 #endif
52 
53 #if(defined(GLM_MESSAGES) && !defined(glm_ext))
54 # pragma message("GLM: GLM_GTX_simd_mat4 extension included")
55 #endif
56 
57 namespace glm{
58 namespace detail
59 {
62  GLM_ALIGNED_STRUCT(16) fmat4x4SIMD
63  {
64  enum ctor{null};
65 
66  typedef float value_type;
67  typedef fvec4SIMD col_type;
68  typedef fvec4SIMD row_type;
69  typedef std::size_t size_type;
70  static size_type value_size();
71  static size_type col_size();
72  static size_type row_size();
73  static bool is_matrix();
74 
75  fvec4SIMD Data[4];
76 
78  // Constructors
79 
80  fmat4x4SIMD();
81  explicit fmat4x4SIMD(float const & s);
82  explicit fmat4x4SIMD(
83  float const & x0, float const & y0, float const & z0, float const & w0,
84  float const & x1, float const & y1, float const & z1, float const & w1,
85  float const & x2, float const & y2, float const & z2, float const & w2,
86  float const & x3, float const & y3, float const & z3, float const & w3);
87  explicit fmat4x4SIMD(
88  fvec4SIMD const & v0,
89  fvec4SIMD const & v1,
90  fvec4SIMD const & v2,
91  fvec4SIMD const & v3);
92  explicit fmat4x4SIMD(
93  tmat4x4<float> const & m);
94  explicit fmat4x4SIMD(
95  __m128 const in[4]);
96 
97  // Conversions
98  //template <typename U>
99  //explicit tmat4x4(tmat4x4<U> const & m);
100 
101  //explicit tmat4x4(tmat2x2<T> const & x);
102  //explicit tmat4x4(tmat3x3<T> const & x);
103  //explicit tmat4x4(tmat2x3<T> const & x);
104  //explicit tmat4x4(tmat3x2<T> const & x);
105  //explicit tmat4x4(tmat2x4<T> const & x);
106  //explicit tmat4x4(tmat4x2<T> const & x);
107  //explicit tmat4x4(tmat3x4<T> const & x);
108  //explicit tmat4x4(tmat4x3<T> const & x);
109 
110  // Accesses
111  fvec4SIMD & operator[](size_type i);
112  fvec4SIMD const & operator[](size_type i) const;
113 
114  // Unary updatable operators
115  fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
116  fmat4x4SIMD & operator+= (float const & s);
117  fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
118  fmat4x4SIMD & operator-= (float const & s);
119  fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
120  fmat4x4SIMD & operator*= (float const & s);
121  fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
122  fmat4x4SIMD & operator/= (float const & s);
123  fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
124  fmat4x4SIMD & operator++ ();
125  fmat4x4SIMD & operator-- ();
126  };
127 
128  // Binary operators
129  fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
130  fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
131  fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
132 
133  fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
134  fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
135  fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
136 
137  fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
138  fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
139 
140  fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
141  fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
142 
143  fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
144 
145  fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
146  fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
147 
148  fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
149  fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
150 
151  fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
152 
153  // Unary constant operators
154  fmat4x4SIMD const operator- (fmat4x4SIMD const & m);
155  fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
156  fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
157 }//namespace detail
158 
159  typedef detail::fmat4x4SIMD simdMat4;
160 
163 
166  detail::tmat4x4<float> mat4_cast(
167  detail::fmat4x4SIMD const & x);
168 
172  detail::fmat4x4SIMD matrixCompMult(
173  detail::fmat4x4SIMD const & x,
174  detail::fmat4x4SIMD const & y);
175 
180  detail::fmat4x4SIMD outerProduct(
181  detail::fvec4SIMD const & c,
182  detail::fvec4SIMD const & r);
183 
186  detail::fmat4x4SIMD transpose(
187  detail::fmat4x4SIMD const & x);
188 
191  float determinant(
192  detail::fmat4x4SIMD const & m);
193 
196  detail::fmat4x4SIMD inverse(
197  detail::fmat4x4SIMD const & m);
198 
200 }// namespace glm
201 
202 #include "simd_mat4.inl"
203 
204 #endif//(GLM_ARCH != GLM_ARCH_PURE)
205 
206 #endif//GLM_GTX_simd_mat4