HWMatrix Struct Reference

HWMatrix Struct Reference

#include <SSE.h>

Class Description

This class represents a four by four matrix stored in the SSE registers.

Definition at line 265 of file SSE.h.

Public Member Functions

 HWMatrix (void) __attribute__((always_inline))
 
 HWMatrix (const mudbox::Matrix &m) __attribute__((always_inline))
 
void MirrorX (void) __attribute__((always_inline))
 
HWVector Transform (const HWVector &v, float w=1.0f) const __attribute__((always_inline))
 
HWVector ProjectedTransform (const HWVector &v) const __attribute__((always_inline))
 
 MB_SSE_ALIGN16_VAR (__m128 r0)
 
 MB_SSE_ALIGN16_VAR (__m128 r1)
 
 MB_SSE_ALIGN16_VAR (__m128 r2)
 
 MB_SSE_ALIGN16_VAR (__m128 r3)
 

Constructor & Destructor Documentation

HWMatrix ( void  )
inline

Definition at line 267 of file SSE.h.

267 {};
HWMatrix ( const mudbox::Matrix m)
inline

Definition at line 268 of file SSE.h.

269  {
270  r0 = _mm_loadu_ps( &m._11 );
271  r1 = _mm_loadu_ps( &m._21 );
272  r2 = _mm_loadu_ps( &m._31 );
273  r3 = _mm_loadu_ps( &m._41 );
274  };
float _31
Definition: math.h:1282
float _21
Definition: math.h:1281
float _41
Definition: math.h:1283
float _11
Definition: math.h:1280

Member Function Documentation

void MirrorX ( void  )
inline

Definition at line 275 of file SSE.h.

276  {
277  r0 = _mm_shuffle_ps( r0, r0, _MM_SHUFFLE(0, 1, 2, 3) );
278  r1 = _mm_shuffle_ps( r1, r1, _MM_SHUFFLE(0, 1, 2, 3) );
279  r2 = _mm_shuffle_ps( r2, r2, _MM_SHUFFLE(0, 1, 2, 3) );
280  r3 = _mm_shuffle_ps( r3, r3, _MM_SHUFFLE(0, 1, 2, 3) );
281  };
HWVector Transform ( const HWVector v,
float  w = 1.0f 
) const
inline

Definition at line 282 of file SSE.h.

283  {
284  // Represents v * M
285  // v is a row vector.
286 
287  MB_SSE_ALIGN16_VAR(float c[4]) = { w, w, w, w };
288 
289  __m128 v0 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(3,3,3,3) );
290  __m128 v1 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(2,2,2,2) );
291  __m128 v2 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(1,1,1,1) );
292  __m128 v3 = _mm_load_ps( c );
293 
294  __m128 a0 = _mm_mul_ps( v0, r0 );
295  __m128 a1 = _mm_mul_ps( v1, r1 );
296  __m128 a2 = _mm_mul_ps( v2, r2 );
297  __m128 a3 = _mm_mul_ps( v3, r3 );
298 
299  __m128 r = _mm_add_ps( a0, _mm_add_ps( a1, _mm_add_ps( a2, a3 ) ) );
300 
301  HWVector z;
302  z.v = r;
303  return z;
304  };
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
GLdouble GLdouble z
Definition: GLee.h:1393
This class represents a four dimensional vector stored in the SSE registers.
Definition: SSE.h:64
GLfloat GLfloat GLfloat v2
Definition: GLee.h:1736
GLfloat GLfloat v1
Definition: GLee.h:1735
GLfloat v0
Definition: GLee.h:1734
const GLubyte * c
Definition: GLee.h:5419
MB_SSE_ALIGN16_VAR(__m128 r0)
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
GLfloat GLfloat GLfloat GLfloat v3
Definition: GLee.h:1737
HWVector ProjectedTransform ( const HWVector v) const
inline

Definition at line 305 of file SSE.h.

306  {
307  static MB_SSE_ALIGN16_VAR(float c[4]) = { 1, 1, 1, 1 };
308 
309  __m128 v0 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(3,3,3,3) );
310  __m128 v1 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(2,2,2,2) );
311  __m128 v2 = _mm_shuffle_ps( v.v, v.v, _MM_SHUFFLE(1,1,1,1) );
312  __m128 v3 = _mm_load_ps( c );
313 
314  __m128 a0 = _mm_mul_ps( v0, r0 );
315  __m128 a1 = _mm_mul_ps( v1, r1 );
316  __m128 a2 = _mm_mul_ps( v2, r2 );
317  __m128 a3 = _mm_mul_ps( v3, r3 );
318 
319  __m128 r = _mm_add_ps( a0, _mm_add_ps( a1, _mm_add_ps( a2, a3 ) ) );
320  __m128 d = _mm_shuffle_ps( r, r, _MM_SHUFFLE(3,3,3,3) );
321 
322  HWVector z;
323  z.v = _mm_div_ps( r, d );
324  return z;
325  };
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
GLdouble GLdouble z
Definition: GLee.h:1393
This class represents a four dimensional vector stored in the SSE registers.
Definition: SSE.h:64
GLfloat GLfloat GLfloat v2
Definition: GLee.h:1736
GLfloat GLfloat v1
Definition: GLee.h:1735
GLfloat v0
Definition: GLee.h:1734
const GLubyte * c
Definition: GLee.h:5419
MB_SSE_ALIGN16_VAR(__m128 r0)
GLfloat GLfloat GLfloat GLfloat v3
Definition: GLee.h:1737
MB_SSE_ALIGN16_VAR ( __m128  r0)
MB_SSE_ALIGN16_VAR ( __m128  r1)
MB_SSE_ALIGN16_VAR ( __m128  r2)
MB_SSE_ALIGN16_VAR ( __m128  r3)

The documentation for this struct was generated from the following file: