simd_mat4.hpp

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 #ifndef GLM_GTX_simd_mat4
00039 #define GLM_GTX_simd_mat4 GLM_VERSION
00040 
00041 // Dependency:
00042 #include "../glm.hpp"
00043 
00044 #if(GLM_ARCH != GLM_ARCH_PURE)
00045 
00046 #if(GLM_ARCH & GLM_ARCH_SSE2)
00047 #       include "../core/intrinsic_matrix.hpp"
00048 #       include "../gtx/simd_vec4.hpp"
00049 #else
00050 #       error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics"
00051 #endif
00052 
00053 #if(defined(GLM_MESSAGES) && !defined(glm_ext))
00054 #       pragma message("GLM: GLM_GTX_simd_mat4 extension included")
00055 #endif
00056 
00057 namespace glm{
00058 namespace detail
00059 {
00062         GLM_ALIGNED_STRUCT(16) fmat4x4SIMD
00063         {
00064                 enum ctor{null};
00065 
00066                 typedef float value_type;
00067                 typedef fvec4SIMD col_type;
00068                 typedef fvec4SIMD row_type;
00069                 typedef std::size_t size_type;
00070                 static size_type value_size();
00071                 static size_type col_size();
00072                 static size_type row_size();
00073                 static bool is_matrix();
00074 
00075                 fvec4SIMD Data[4];
00076 
00078                 // Constructors
00079 
00080                 fmat4x4SIMD();
00081                 explicit fmat4x4SIMD(float const & s);
00082                 explicit fmat4x4SIMD(
00083                         float const & x0, float const & y0, float const & z0, float const & w0,
00084                         float const & x1, float const & y1, float const & z1, float const & w1,
00085                         float const & x2, float const & y2, float const & z2, float const & w2,
00086                         float const & x3, float const & y3, float const & z3, float const & w3);
00087                 explicit fmat4x4SIMD(
00088                         fvec4SIMD const & v0,
00089                         fvec4SIMD const & v1,
00090                         fvec4SIMD const & v2,
00091                         fvec4SIMD const & v3);
00092                 explicit fmat4x4SIMD(
00093                         tmat4x4<float> const & m);
00094 
00095                 // Conversions
00096                 //template <typename U> 
00097                 //explicit tmat4x4(tmat4x4<U> const & m);
00098 
00099                 //explicit tmat4x4(tmat2x2<T> const & x);
00100                 //explicit tmat4x4(tmat3x3<T> const & x);
00101                 //explicit tmat4x4(tmat2x3<T> const & x);
00102                 //explicit tmat4x4(tmat3x2<T> const & x);
00103                 //explicit tmat4x4(tmat2x4<T> const & x);
00104                 //explicit tmat4x4(tmat4x2<T> const & x);
00105                 //explicit tmat4x4(tmat3x4<T> const & x);
00106                 //explicit tmat4x4(tmat4x3<T> const & x);
00107 
00108                 // Accesses
00109                 fvec4SIMD & operator[](size_type i);
00110                 fvec4SIMD const & operator[](size_type i) const;
00111 
00112                 // Unary updatable operators
00113                 fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
00114                 fmat4x4SIMD & operator+= (float const & s);
00115                 fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
00116                 fmat4x4SIMD & operator-= (float const & s);
00117                 fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
00118                 fmat4x4SIMD & operator*= (float const & s);
00119                 fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
00120                 fmat4x4SIMD & operator/= (float const & s);
00121                 fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
00122                 fmat4x4SIMD & operator++ ();
00123                 fmat4x4SIMD & operator-- ();
00124         };
00125 
00126         // Binary operators
00127         fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
00128         fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
00129         fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00130             
00131         fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
00132         fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
00133         fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00134 
00135         fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
00136         fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
00137 
00138         fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
00139         fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
00140 
00141         fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00142 
00143         fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
00144         fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
00145 
00146         fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
00147         fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
00148 
00149         fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00150 
00151         // Unary constant operators
00152         fmat4x4SIMD const operator-  (fmat4x4SIMD const & m);
00153         fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
00154         fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
00155 }//namespace detail
00156 
00157         typedef detail::fmat4x4SIMD simdMat4;
00158 
00161 
00164         detail::tmat4x4<float> mat4_cast(
00165                 detail::fmat4x4SIMD const & x);
00166 
00170         detail::fmat4x4SIMD matrixCompMult(
00171                 detail::fmat4x4SIMD const & x,
00172                 detail::fmat4x4SIMD const & y);
00173 
00178         detail::fmat4x4SIMD outerProduct(
00179                 detail::fvec4SIMD const & c,
00180                 detail::fvec4SIMD const & r);
00181 
00184         detail::fmat4x4SIMD transpose(
00185                 detail::fmat4x4SIMD const & x);
00186 
00189         float determinant(
00190                 detail::fmat4x4SIMD const & m);
00191 
00194         detail::fmat4x4SIMD inverse(
00195                 detail::fmat4x4SIMD const & m);
00196 
00198 }// namespace glm
00199 
00200 #include "simd_mat4.inl"
00201 
00202 #endif//(GLM_ARCH != GLM_ARCH_PURE)
00203 
00204 #endif//GLM_GTX_simd_mat4