Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TF_QUADWORD_H
00017 #define TF_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
00028 namespace tf
00029 {
00033 #ifndef USE_LIBSPE2
00034 ATTRIBUTE_ALIGNED16(class) QuadWord
00035 #else
00036 class QuadWord
00037 #endif
00038 {
00039 protected:
00040
00041 #if defined (__SPU__) && defined (__CELLOS_LV2__)
00042 union {
00043 vec_float4 mVec128;
00044 tfScalar m_floats[4];
00045 };
00046 public:
00047 vec_float4 get128() const
00048 {
00049 return mVec128;
00050 }
00051 protected:
00052 #else //__CELLOS_LV2__ __SPU__
00053 tfScalar m_floats[4];
00054 #endif //__CELLOS_LV2__ __SPU__
00055
00056 public:
00057
00058
00060 TFSIMD_FORCE_INLINE const tfScalar& getX() const { return m_floats[0]; }
00062 TFSIMD_FORCE_INLINE const tfScalar& getY() const { return m_floats[1]; }
00064 TFSIMD_FORCE_INLINE const tfScalar& getZ() const { return m_floats[2]; }
00066 TFSIMD_FORCE_INLINE void setX(tfScalar x) { m_floats[0] = x;};
00068 TFSIMD_FORCE_INLINE void setY(tfScalar y) { m_floats[1] = y;};
00070 TFSIMD_FORCE_INLINE void setZ(tfScalar z) { m_floats[2] = z;};
00072 TFSIMD_FORCE_INLINE void setW(tfScalar w) { m_floats[3] = w;};
00074 TFSIMD_FORCE_INLINE const tfScalar& x() const { return m_floats[0]; }
00076 TFSIMD_FORCE_INLINE const tfScalar& y() const { return m_floats[1]; }
00078 TFSIMD_FORCE_INLINE const tfScalar& z() const { return m_floats[2]; }
00080 TFSIMD_FORCE_INLINE const tfScalar& w() const { return m_floats[3]; }
00081
00082
00083
00085 TFSIMD_FORCE_INLINE operator tfScalar *() { return &m_floats[0]; }
00086 TFSIMD_FORCE_INLINE operator const tfScalar *() const { return &m_floats[0]; }
00087
00088 TFSIMD_FORCE_INLINE bool operator==(const QuadWord& other) const
00089 {
00090 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]));
00091 }
00092
00093 TFSIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const
00094 {
00095 return !(*this == other);
00096 }
00097
00103 TFSIMD_FORCE_INLINE void setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z)
00104 {
00105 m_floats[0]=x;
00106 m_floats[1]=y;
00107 m_floats[2]=z;
00108 m_floats[3] = 0.f;
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00124 TFSIMD_FORCE_INLINE void setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w)
00125 {
00126 m_floats[0]=x;
00127 m_floats[1]=y;
00128 m_floats[2]=z;
00129 m_floats[3]=w;
00130 }
00132 TFSIMD_FORCE_INLINE QuadWord()
00133
00134 {
00135 }
00136
00142 TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z)
00143 {
00144 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
00145 }
00146
00153 TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w)
00154 {
00155 m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
00156 }
00157
00161 TFSIMD_FORCE_INLINE void setMax(const QuadWord& other)
00162 {
00163 tfSetMax(m_floats[0], other.m_floats[0]);
00164 tfSetMax(m_floats[1], other.m_floats[1]);
00165 tfSetMax(m_floats[2], other.m_floats[2]);
00166 tfSetMax(m_floats[3], other.m_floats[3]);
00167 }
00171 TFSIMD_FORCE_INLINE void setMin(const QuadWord& other)
00172 {
00173 tfSetMin(m_floats[0], other.m_floats[0]);
00174 tfSetMin(m_floats[1], other.m_floats[1]);
00175 tfSetMin(m_floats[2], other.m_floats[2]);
00176 tfSetMin(m_floats[3], other.m_floats[3]);
00177 }
00178
00179
00180
00181 };
00182
00183 }
00184
00185 #endif //TFSIMD_QUADWORD_H