This class represents a four dimensional vector stored in the SSE registers.
#include <SSE.h>
Public Member Functions |
|
| HWVector (void) | |
| void | setZero (void) |
| HWVector (float f) | |
| HWVector (const mudbox::Vector &h) | |
| HWVector (float x, float y, float z, float w=0) | |
| void | Fill (const mudbox::Vector &vVector) |
| HWVector (const float a[4]) | |
| HWVector | ShiftLeft (void) const |
| void | ShiftLeft (HWVector &result) |
| void | ShiftLeftInPlace () |
| HWVector | ShiftRight (void) const |
| void | ShiftRight (HWVector &result) |
| HWVector | operator& (HWVector &o) |
| HWVector | operator| (const HWVector &o) const |
| HWVector | Length (void) const |
| HWVector | LengthSquared (void) const |
| float | DistanceFromLine (const HWVector &vStart, const HWVector &vEnd) const |
| void | Normalize (void) |
| HWVector | Floor (void) |
| HWVector | Minimum (const HWVector &o) const |
| HWVector | Maximum (const HWVector &o) const |
| HWVector | operator+ (const HWVector &o) const |
| HWVector | operator- (const HWVector &o) const |
| void | operator+= (const HWVector &o) |
| void | operator-= (const HWVector &o) |
| void | operator*= (const HWVector &o) |
| void | operator/= (const HWVector &o) |
| HWVector | operator* (const HWVector &o) const |
| HWVector | operator* (float f) const |
| HWVector | operator/ (const HWVector &o) const |
| void | operator*= (float f) |
| void | Store (float *p) |
| void | Load (float f) |
| void | StoreNormalAsInt (int *pBuffer) const |
| void | StoreAsInt (int *pBuffer) const |
| operator float (void) const | |
| operator mudbox::Vector (void) const | |
| operator mudbox::Vector4 (void) const | |
| MB_SSE_ALIGN16_VAR (__m128 v) | |
| HWVector | ( | const mudbox::Vector & | h | ) | [inline] |
| HWVector | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | w = 0 |
||
| ) | [inline] |
| HWVector | ( | const float | a[4] | ) | [inline] |
| void setZero | ( | void | ) | [inline] |
| void Fill | ( | const mudbox::Vector & | vVector | ) |
| HWVector ShiftLeft | ( | void | ) | const [inline] |
| void ShiftLeft | ( | HWVector & | result | ) | [inline] |
| void ShiftLeftInPlace | ( | ) | [inline] |
| HWVector ShiftRight | ( | void | ) | const [inline] |
| void ShiftRight | ( | HWVector & | result | ) | [inline] |
Definition at line 90 of file SSE.h.
{
//HWVector al = (*this).ShiftLeft(), bl = o.ShiftLeft(), ar = (*this).ShiftRight(), br = o.ShiftRight();
HWVector al, bl, ar, br;
ShiftLeft(al);
o.ShiftLeft(bl);
ShiftRight(ar);
o.ShiftRight(br);
return al*br-ar*bl;
};
| HWVector Length | ( | void | ) | const [inline] |
Definition at line 112 of file SSE.h.
{
HWVector r = operator |( *this );
r.v = _mm_sqrt_ss( r.v );
return r;
};
| HWVector LengthSquared | ( | void | ) | const [inline] |
Definition at line 119 of file SSE.h.
{
HWVector r = operator |( *this );
return r;
};
| void Normalize | ( | void | ) | [inline] |
Definition at line 136 of file SSE.h.
{
HWVector f = operator |( *this );
f.v = _mm_rsqrt_ps( f.v );
v = _mm_mul_ps( f.v, v );
};
| HWVector Floor | ( | void | ) | [inline] |
Definition at line 143 of file SSE.h.
{
static unsigned int a = 1<<23;
static float twoTo23AsFloat = (float)a;
static const __m128 twoTo23 = _mm_set_ps( twoTo23AsFloat,twoTo23AsFloat,twoTo23AsFloat,twoTo23AsFloat );
// b = fabs(v)
__m128 b = _mm_castsi128_ps(_mm_srli_epi32( _mm_slli_epi32( _mm_castps_si128(v),1 ), 1 ));
// The essence of the floor routine
__m128 d = _mm_sub_ps( _mm_add_ps( _mm_add_ps( _mm_sub_ps( v,twoTo23 ), twoTo23 ),twoTo23 ), twoTo23 );
// �1 if v >= 2**23
__m128 largeMaskE = _mm_cmpgt_ps( b, twoTo23 );
// Check for possible off by one error
__m128 g = _mm_cmplt_ps( v, d );
// Convert positive check result to -1.0, negative to 0.0
__m128 h = _mm_cvtepi32_ps( _mm_castps_si128(g) );
// Add in the error if there is one
__m128 t = _mm_add_ps( d, h );
//Select between output result and input value based on v >= 2**23
__m128 w = _mm_and_ps( v, largeMaskE );
t = _mm_andnot_ps( largeMaskE, t );
HWVector vResult;
vResult.v = _mm_or_ps( t, w );
return vResult;
};
| void operator+= | ( | const HWVector & | o | ) | [inline] |
| void operator-= | ( | const HWVector & | o | ) | [inline] |
| void operator*= | ( | const HWVector & | o | ) | [inline] |
| void operator/= | ( | const HWVector & | o | ) | [inline] |
| HWVector operator* | ( | float | f | ) | const [inline] |
| void operator*= | ( | float | f | ) | [inline] |
| void Store | ( | float * | p | ) | [inline] |
| void Load | ( | float | f | ) | [inline] |
| void StoreNormalAsInt | ( | int * | pBuffer | ) | const [inline] |
Definition at line 182 of file SSE.h.
{
//static __declspec(align(16)) float c[4] = { 32766.0f, 32766.0f, 32766.0f, 32766.0f };
// instead of the correct value, we use a little bit smaller number, because after
// normalization a component can be a littlebit bigger than 1.0. in that case storing it in
// a 16 bit integer would overflow, and artifacts on the surface would appear.
static const MB_SSE_ALIGN16_VAR(float c[4]) = { 32740.0f, 32740.0f, 32740.0f, 32740.0f };
__m128 f = _mm_load_ps( c );
f = _mm_mul_ps( f, v );
__m128i i = _mm_cvtps_epi32( f );
_mm_storeu_si128( (__m128i *)pBuffer, i );
};
| void StoreAsInt | ( | int * | pBuffer | ) | const [inline] |
| operator float | ( | void | ) | const [inline] |
Definition at line 200 of file SSE.h.
{
MB_SSE_ALIGN16_VAR(float f);
_mm_store_ss( &f, v );
return f;
};
| operator mudbox::Vector | ( | void | ) | const [inline] |
Definition at line 206 of file SSE.h.
{
mudbox::Vector r;
__m128 t = _mm_shuffle_ps( v, v, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.x, t );
t = _mm_shuffle_ps( t, t, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.y, t );
t = _mm_shuffle_ps( t, t, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.z, t );
return r;
};
| operator mudbox::Vector4 | ( | void | ) | const [inline] |
Definition at line 217 of file SSE.h.
{
mudbox::Vector4 r;
__m128 t = _mm_shuffle_ps( v, v, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.x, t );
t = _mm_shuffle_ps( t, t, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.y, t );
t = _mm_shuffle_ps( t, t, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.z, t );
t = _mm_shuffle_ps( t, t, _MM_SHUFFLE(2,1,0,3) );
_mm_store_ss( &r.w, t );
return r;
};
| MB_SSE_ALIGN16_VAR | ( | __m128 | v | ) |