Merge commit '1bef2b2'

This commit is contained in:
Phillip Stephens 2016-01-16 15:17:13 -08:00
commit 0594099ccd
3 changed files with 132 additions and 55 deletions

View File

@ -16,8 +16,22 @@ namespace Zeus
{ {
class alignas(16) CVector2f class alignas(16) CVector2f
{ {
public: #if __atdna__
float clangVec __attribute__((__vector_size__(8)));
#endif
public:
ZE_DECLARE_ALIGNED_ALLOCATOR(); ZE_DECLARE_ALIGNED_ALLOCATOR();
union
{
struct
{
float x, y;
};
float v[4];
#if __SSE__
__m128 mVec128;
#endif
};
inline CVector2f() {zeroOut();} inline CVector2f() {zeroOut();}
#if __SSE__ #if __SSE__
@ -32,20 +46,44 @@ class alignas(16) CVector2f
x = vec.vec[0], y = vec.vec[1], v[2] = 0.0f, v[3] = 0.0f; x = vec.vec[0], y = vec.vec[1], v[2] = 0.0f, v[3] = 0.0f;
} }
#endif #endif
operator atVec2f()
{
atVec2f ret;
#if __SSE__
ret.mVec128 = mVec128;
#else
ret.vec = v;
#endif #endif
CVector2f(float xy) {splat(xy);} return ret;
void assign(float x, float y) {v[0] = x; v[1] = y; v[2] = 0; v[3] = 0.0;} }
CVector2f(float x, float y) {assign(x, y);} operator atVec2f() const
#if ZE_ATHENA_TYPES {
CVector2f(Athena::io::IStreamReader& input) atVec2f ret;
#if __SSE__
ret.mVec128 = mVec128;
#else
ret.vec = v;
#endif
return ret;
}
void read(Athena::io::IStreamReader& input)
{ {
x = input.readFloat(); x = input.readFloat();
y = input.readFloat(); y = input.readFloat();
v[2] = 0.0f; v[2] = 0.0f;
v[3] = 0.0f; v[3] = 0.0f;
} }
CVector2f(Athena::io::IStreamReader& input)
{ read(input); }
#endif #endif
CVector2f(float xy) {splat(xy);}
void assign(float x, float y) {v[0] = x; v[1] = y; v[2] = 0; v[3] = 0.0;}
CVector2f(float x, float y) {assign(x, y);}
inline bool operator ==(const CVector2f& rhs) const inline bool operator ==(const CVector2f& rhs) const
{return (x == rhs.x && y == rhs.y);} {return (x == rhs.x && y == rhs.y);}
inline bool operator !=(const CVector2f& rhs) const inline bool operator !=(const CVector2f& rhs) const
@ -307,18 +345,6 @@ class alignas(16) CVector2f
inline const float& operator[](size_t idx) const {return (&x)[idx];} inline const float& operator[](size_t idx) const {return (&x)[idx];}
union
{
struct
{
float x, y;
};
float v[4];
#if __SSE__
__m128 mVec128;
#endif
};
static const CVector2f skOne; static const CVector2f skOne;
static const CVector2f skNegOne; static const CVector2f skNegOne;
static const CVector2f skZero; static const CVector2f skZero;

View File

@ -16,13 +16,28 @@ namespace Zeus
{ {
class alignas(16) CVector3f class alignas(16) CVector3f
{ {
#if __atdna__
float clangVec __attribute__((__vector_size__(12)));
#endif
public: public:
ZE_DECLARE_ALIGNED_ALLOCATOR(); ZE_DECLARE_ALIGNED_ALLOCATOR();
union
{
struct { float x, y, z; };
float v[4];
#if __SSE__
__m128 mVec128;
#elif __GEKKO_PS__
ps128_t mVec128;
#endif
};
inline CVector3f() {zeroOut();} inline CVector3f() {zeroOut();}
#if __SSE__ || __GEKKO_PS__ #if __SSE__ || __GEKKO_PS__
CVector3f(const __m128& mVec128) : mVec128(mVec128) {v[3] = 0.0f;} CVector3f(const __m128& mVec128) : mVec128(mVec128) {v[3] = 0.0f;}
#endif #endif
#if ZE_ATHENA_TYPES #if ZE_ATHENA_TYPES
CVector3f(const atVec3f& vec) CVector3f(const atVec3f& vec)
#if __SSE__ || __GEKKO_PS__ #if __SSE__ || __GEKKO_PS__
@ -32,11 +47,28 @@ public:
x = vec.vec[0], y = vec.vec[1], z = vec.vec[2], v[3] = 0.0f; x = vec.vec[0], y = vec.vec[1], z = vec.vec[2], v[3] = 0.0f;
} }
#endif #endif
operator atVec3f()
{
atVec3f ret;
#if __SSE__
ret.mVec128 = mVec128;
#else
ret.vec = v;
#endif #endif
CVector3f(float xyz) {splat(xyz);} return ret;
void assign(float x, float y, float z) {v[0] = x; v[1] = y; v[2] = z; v[3] = 0.0;} }
CVector3f(float x, float y, float z) {assign(x, y, z);} operator atVec3f() const
#if ZE_ATHENA_TYPES {
atVec3f ret;
#if __SSE__
ret.mVec128 = mVec128;
#else
ret.vec = v;
#endif
return ret;
}
void read(Athena::io::IStreamReader& input) void read(Athena::io::IStreamReader& input)
{ {
x = input.readFloat(); x = input.readFloat();
@ -46,6 +78,11 @@ public:
} }
CVector3f(Athena::io::IStreamReader& input) {read(input);} CVector3f(Athena::io::IStreamReader& input) {read(input);}
#endif #endif
CVector3f(float xyz) {splat(xyz);}
void assign(float x, float y, float z) {v[0] = x; v[1] = y; v[2] = z; v[3] = 0.0;}
CVector3f(float x, float y, float z) {assign(x, y, z);}
CVector3f(const CVector2f& other) CVector3f(const CVector2f& other)
{ {
x = other.x; x = other.x;
@ -313,18 +350,6 @@ public:
inline float& operator[](size_t idx) {return (&x)[idx];} inline float& operator[](size_t idx) {return (&x)[idx];}
inline const float& operator[](size_t idx) const {return (&x)[idx];} inline const float& operator[](size_t idx) const {return (&x)[idx];}
union
{
struct { float x, y, z; };
float v[4];
#if __SSE__
__m128 mVec128;
#elif __GEKKO_PS__
ps128_t mVec128;
#endif
};
static const CVector3f skOne; static const CVector3f skOne;
static const CVector3f skNegOne; static const CVector3f skNegOne;
static const CVector3f skZero; static const CVector3f skZero;

View File

@ -16,8 +16,22 @@ namespace Zeus
class CColor; class CColor;
class alignas(16) CVector4f class alignas(16) CVector4f
{ {
public: #if __atdna__
float clangVec __attribute__((__vector_size__(16)));
#endif
public:
ZE_DECLARE_ALIGNED_ALLOCATOR(); ZE_DECLARE_ALIGNED_ALLOCATOR();
union
{
struct
{
float x, y, z, w;
};
float v[4];
#if __SSE__
__m128 mVec128;
#endif
};
inline CVector4f() {zeroOut();} inline CVector4f() {zeroOut();}
#if __SSE__ #if __SSE__
@ -31,23 +45,47 @@ class alignas(16) CVector4f
{ {
x = vec.vec[0], y = vec.vec[1], z = vec.vec[2], w = vec.vec[3]; x = vec.vec[0], y = vec.vec[1], z = vec.vec[2], w = vec.vec[3];
} }
#endif
#endif #endif
CVector4f(float xyzw) {splat(xyzw);} operator atVec4f()
void assign(float x, float y, float z, float w) {v[0] = x; v[1] = y; v[2] = z; v[3] = w;} {
CVector4f(float x, float y, float z, float w) {assign(x, y, z, w);} atVec4f ret;
CVector4f(const CColor& other); #if __SSE__
#if ZE_ATHENA_TYPES ret.mVec128 = mVec128;
CVector4f(Athena::io::IStreamReader& input) #else
ret.vec = v;
#endif
return ret;
}
operator atVec4f() const
{
atVec4f ret;
#if __SSE__
ret.mVec128 = mVec128;
#else
ret.vec = v;
#endif
return ret;
}
void read(Athena::io::IStreamReader& input)
{ {
x = input.readFloat(); x = input.readFloat();
y = input.readFloat(); y = input.readFloat();
z = input.readFloat(); z = input.readFloat();
w = input.readFloat(); w = input.readFloat();
} }
CVector4f(Athena::io::IStreamReader& input)
{ read(input); }
#endif #endif
CVector4f(float xyzw) {splat(xyzw);}
void assign(float x, float y, float z, float w) {v[0] = x; v[1] = y; v[2] = z; v[3] = w;}
CVector4f(float x, float y, float z, float w) {assign(x, y, z, w);}
CVector4f(const CColor& other);
CVector4f(const CVector3f& other) CVector4f(const CVector3f& other)
{ {
x = other.x; x = other.x;
@ -325,18 +363,6 @@ class alignas(16) CVector4f
inline const float& operator[](size_t idx) const {return (&x)[idx];} inline const float& operator[](size_t idx) const {return (&x)[idx];}
union
{
struct
{
float x, y, z, w;
};
float v[4];
#if __SSE__
__m128 mVec128;
#endif
};
static const CVector4f skOne; static const CVector4f skOne;
static const CVector4f skNegOne; static const CVector4f skNegOne;
static const CVector4f skZero; static const CVector4f skZero;