Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TF2SIMD_QUADWORD_H
00017 #define TF2SIMD_QUADWORD_H
00018
00019 #include "Scalar.h"
00020 #include "MinMax.h"
00021
00022
00023 #if defined (__CELLOS_LV2) && defined (__SPU__)
00024 #include <altivec.h>
00025 #endif
00026
00027 namespace tf2
00028 {
00032 #ifndef USE_LIBSPE2
00033 ATTRIBUTE_ALIGNED16(class) QuadWord
00034 #else
00035 class QuadWord
00036 #endif
00037 {
00038 protected:
00039
00040 #if defined (__SPU__) && defined (__CELLOS_LV2__)
00041 union {
00042 vec_float4 mVec128;
00043 tf2Scalar m_floats[4];
00044 };
00045 public:
00046 vec_float4 get128() const
00047 {
00048 return mVec128;
00049 }
00050 protected:
00051 #else //__CELLOS_LV2__ __SPU__
00052 tf2Scalar m_floats[4];
00053 #endif //__CELLOS_LV2__ __SPU__
00054
00055 public:
00056
00057
00059 TF2SIMD_FORCE_INLINE const tf2Scalar& getX() const { return m_floats[0]; }
00061 TF2SIMD_FORCE_INLINE const tf2Scalar& getY() const { return m_floats[1]; }
00063 TF2SIMD_FORCE_INLINE const tf2Scalar& getZ() const { return m_floats[2]; }
00065 TF2SIMD_FORCE_INLINE void setX(tf2Scalar x) { m_floats[0] = x;};
00067 TF2SIMD_FORCE_INLINE void setY(tf2Scalar y) { m_floats[1] = y;};
00069 TF2SIMD_FORCE_INLINE void setZ(tf2Scalar z) { m_floats[2] = z;};
00071 TF2SIMD_FORCE_INLINE void setW(tf2Scalar w) { m_floats[3] = w;};
00073 TF2SIMD_FORCE_INLINE const tf2Scalar& x() const { return m_floats[0]; }
00075 TF2SIMD_FORCE_INLINE const tf2Scalar& y() const { return m_floats[1]; }
00077 TF2SIMD_FORCE_INLINE const tf2Scalar& z() const { return m_floats[2]; }
00079 TF2SIMD_FORCE_INLINE const tf2Scalar& w() const { return m_floats[3]; }
00080
00081
00082
00084 TF2SIMD_FORCE_INLINE operator tf2Scalar *() { return &m_floats[0]; }
00085 TF2SIMD_FORCE_INLINE operator const tf2Scalar *() const { return &m_floats[0]; }
00086
00087 TF2SIMD_FORCE_INLINE bool operator==(const QuadWord& other) const
00088 {
00089 return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0]));
00090 }
00091
00092 TF2SIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const
00093 {
00094 return !(*this == other);
00095 }
00096
00102 TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
00103 {
00104 m_floats[0]=x;
00105 m_floats[1]=y;
00106 m_floats[2]=z;
00107 m_floats[3] = 0.f;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00123 TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
00124 {
00125 m_floats[0]=x;
00126 m_floats[1]=y;
00127 m_floats[2]=z;
00128 m_floats[3]=w;
00129 }
00131 TF2SIMD_FORCE_INLINE QuadWord()
00132
00133 {
00134 }
00135
00141 TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
00142 {
00143 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
00144 }
00145
00152 TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
00153 {
00154 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
00155 }
00156
00160 TF2SIMD_FORCE_INLINE void setMax(const QuadWord& other)
00161 {
00162 tf2SetMax(m_floats[0], other.m_floats[0]);
00163 tf2SetMax(m_floats[1], other.m_floats[1]);
00164 tf2SetMax(m_floats[2], other.m_floats[2]);
00165 tf2SetMax(m_floats[3], other.m_floats[3]);
00166 }
00170 TF2SIMD_FORCE_INLINE void setMin(const QuadWord& other)
00171 {
00172 tf2SetMin(m_floats[0], other.m_floats[0]);
00173 tf2SetMin(m_floats[1], other.m_floats[1]);
00174 tf2SetMin(m_floats[2], other.m_floats[2]);
00175 tf2SetMin(m_floats[3], other.m_floats[3]);
00176 }
00177
00178
00179
00180 };
00181
00182 }
00183 #endif //TF2SIMD_QUADWORD_H