mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 11:24:35 +00:00
Removed extension for intrinsic branche
This commit is contained in:
parent
d462852ff9
commit
679e46ae98
@ -1,141 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2009-05-07
|
||||
// Updated : 2009-05-07
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/simd_vec4.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Dependency:
|
||||
// - GLM core
|
||||
// - intrinsic
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef glm_gtx_simd_mat4
|
||||
#define glm_gtx_simd_mat4
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
namespace glm
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
GLM_ALIGN(16) struct fmat4x4SIMD
|
||||
{
|
||||
static __m128 one;
|
||||
|
||||
enum no_init
|
||||
{
|
||||
NO_INIT
|
||||
};
|
||||
|
||||
typedef float value_type;
|
||||
typedef fvec4SIMD col_type;
|
||||
typedef fvec4SIMD row_type;
|
||||
typedef glm::sizeType size_type;
|
||||
static size_type value_size();
|
||||
static size_type col_size();
|
||||
static size_type row_size();
|
||||
static bool is_matrix();
|
||||
|
||||
fvec4SIMD Data[4];
|
||||
|
||||
//////////////////////////////////////
|
||||
// Constructors
|
||||
|
||||
fmat4x4SIMD();
|
||||
explicit fmat4x4SIMD(float const & s);
|
||||
explicit fmat4x4SIMD(
|
||||
float const & x0, float const & y0, float const & z0, float const & w0,
|
||||
float const & x1, float const & y1, float const & z1, float const & w1,
|
||||
float const & x2, float const & y2, float const & z2, float const & w2,
|
||||
float const & x3, float const & y3, float const & z3, float const & w3);
|
||||
explicit fmat4x4SIMD(
|
||||
fvec4SIMD const & v0,
|
||||
fvec4SIMD const & v1,
|
||||
fvec4SIMD const & v2,
|
||||
fvec4SIMD const & v3);
|
||||
explicit fmat4x4SIMD(
|
||||
tmat4x4 const & m);
|
||||
|
||||
// Conversions
|
||||
//template <typename U>
|
||||
//explicit tmat4x4(tmat4x4<U> const & m);
|
||||
|
||||
//explicit tmat4x4(tmat2x2<T> const & x);
|
||||
//explicit tmat4x4(tmat3x3<T> const & x);
|
||||
//explicit tmat4x4(tmat2x3<T> const & x);
|
||||
//explicit tmat4x4(tmat3x2<T> const & x);
|
||||
//explicit tmat4x4(tmat2x4<T> const & x);
|
||||
//explicit tmat4x4(tmat4x2<T> const & x);
|
||||
//explicit tmat4x4(tmat3x4<T> const & x);
|
||||
//explicit tmat4x4(tmat4x3<T> const & x);
|
||||
|
||||
// Accesses
|
||||
fvec4SIMD & operator[](size_type i);
|
||||
fvec4SIMD const & operator[](size_type i) const;
|
||||
|
||||
// Unary updatable operators
|
||||
fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD & operator+= (float const & s);
|
||||
fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD & operator-= (float const & s);
|
||||
fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD & operator*= (float const & s);
|
||||
fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD & operator/= (float const & s);
|
||||
fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD & operator++ ();
|
||||
fmat4x4SIMD & operator-- ();
|
||||
};
|
||||
|
||||
// Binary operators
|
||||
fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
||||
fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
||||
fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
|
||||
|
||||
fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
|
||||
fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
|
||||
|
||||
fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
||||
fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
|
||||
|
||||
fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
|
||||
fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
|
||||
|
||||
fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
||||
// Unary constant operators
|
||||
fmat4x4SIMD const operator- (fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
|
||||
fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
|
||||
|
||||
}//namespace detail
|
||||
|
||||
namespace gtx{
|
||||
//! GLM_GTX_simd_mat4 extension: SIMD implementation of vec4 type.
|
||||
namespace simd_mat4
|
||||
{
|
||||
typedef detail::fmat4SIMD mat4SIMD;
|
||||
|
||||
}//namespace simd_mat4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
||||
#include "simd_mat4.inl"
|
||||
|
||||
namespace glm{using namespace gtx::simd_mat4;}
|
||||
|
||||
#endif//glm_gtx_simd_mat4
|
@ -1,221 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2009-05-19
|
||||
// Updated : 2009-05-19
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/simd_mat4.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
inline fmat4x4SIMD::fmat4x4SIMD()
|
||||
{}
|
||||
|
||||
inline fmat4x4SIMD::fmat4x4SIMD(float const & s)
|
||||
{
|
||||
this->value[0] = fvec4SIMD(s, 0, 0, 0);
|
||||
this->value[1] = fvec4SIMD(0, s, 0, 0);
|
||||
this->value[2] = fvec4SIMD(0, 0, s, 0);
|
||||
this->value[3] = fvec4SIMD(0, 0, 0, s);
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD::fmat4x4SIMD
|
||||
(
|
||||
float const & x0, float const & y0, float const & z0, float const & w0,
|
||||
float const & x1, float const & y1, float const & z1, float const & w1,
|
||||
float const & x2, float const & y2, float const & z2, float const & w2,
|
||||
float const & x3, float const & y3, float const & z3, float const & w3
|
||||
)
|
||||
{
|
||||
this->value[0] = fvec4SIMD(x0, y0, z0, w0);
|
||||
this->value[1] = fvec4SIMD(x1, y1, z1, w1);
|
||||
this->value[2] = fvec4SIMD(x2, y2, z2, w2);
|
||||
this->value[3] = fvec4SIMD(x3, y3, z3, w3);
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD::fmat4x4SIMD
|
||||
(
|
||||
fvec4SIMD const & v0,
|
||||
fvec4SIMD const & v1,
|
||||
fvec4SIMD const & v2,
|
||||
fvec4SIMD const & v3
|
||||
)
|
||||
{
|
||||
this->value[0] = v0;
|
||||
this->value[1] = v1;
|
||||
this->value[2] = v2;
|
||||
this->value[3] = v3;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD::fmat4x4SIMD
|
||||
(
|
||||
tmat4x4 const & m
|
||||
)
|
||||
{
|
||||
this->value[0] = fvec4SIMD(m[0]);
|
||||
this->value[1] = fvec4SIMD(m[1]);
|
||||
this->value[2] = fvec4SIMD(m[2]);
|
||||
this->value[3] = fvec4SIMD(m[3]);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
inline fvec4SIMD & fmat4x4SIMD::operator[]
|
||||
(
|
||||
typename fmat4x4SIMD::size_type i
|
||||
)
|
||||
{
|
||||
assert(
|
||||
i >= typename tmat4x4<valType>::size_type(0) &&
|
||||
i < tmat4x4<valType>::col_size());
|
||||
|
||||
return value[i];
|
||||
}
|
||||
|
||||
inline fvec4SIMD const & fmat4x4SIMD::operator[]
|
||||
(
|
||||
typename fmat4x4SIMD::size_type i
|
||||
) const
|
||||
{
|
||||
assert(
|
||||
i >= typename fmat4x4SIMD::size_type(0) &&
|
||||
i < fmat4x4SIMD::col_size());
|
||||
|
||||
return value[i];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// mat4 operators
|
||||
|
||||
inline fmat4x4SIMD& fmat4x4SIMD::operator=
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
this->value[0].Data = m[0].Data;
|
||||
this->value[1].Data = m[1].Data;
|
||||
this->value[2].Data = m[2].Data;
|
||||
this->value[3].Data = m[3].Data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator+=
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, m[0].Data);
|
||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, m[1].Data);
|
||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, m[2].Data);
|
||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, m[3].Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator-=
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, m[0].Data);
|
||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, m[1].Data);
|
||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, m[2].Data);
|
||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, m[3].Data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator*=
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
_mm_mul_ps(this->Data, m.Data, this->Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator/=
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
__m128 Inv[4];
|
||||
_mm_inverse_ps(m.Data, Inv);
|
||||
_mm_mul_ps(this->Data, Inv, this->Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator+=
|
||||
(
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
__m128 Operand = _mm_set_ps1(s);
|
||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, Operand);
|
||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, Operand);
|
||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, Operand);
|
||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, Operand);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator-=
|
||||
(
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
__m128 Operand = _mm_set_ps1(s);
|
||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, Operand);
|
||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, Operand);
|
||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, Operand);
|
||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, Operand);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator*=
|
||||
(
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
__m128 Operand = _mm_set_ps1(s);
|
||||
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
|
||||
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
|
||||
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
|
||||
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator/=
|
||||
(
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
__m128 Operand = _mm_div_ps(one, s));
|
||||
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
|
||||
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
|
||||
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
|
||||
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator++ ()
|
||||
{
|
||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, one);
|
||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, one);
|
||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, one);
|
||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, one);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fmat4x4SIMD & fmat4x4SIMD::operator-- ()
|
||||
{
|
||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, one);
|
||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, one);
|
||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, one);
|
||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, one);
|
||||
return *this;
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
}//namespace glm
|
@ -1,127 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2009-05-07
|
||||
// Updated : 2009-05-07
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/simd_vec4.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Dependency:
|
||||
// - GLM core
|
||||
// - intrinsic
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef glm_gtx_simd_vec4
|
||||
#define glm_gtx_simd_vec4
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
#include "../core/intrinsic_common.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
GLM_ALIGN(4) struct fvec4SIMD
|
||||
{
|
||||
static __m128 one;
|
||||
|
||||
union
|
||||
{
|
||||
__m128 Data;
|
||||
struct{float x, y, z, w;};
|
||||
float array[4];
|
||||
};
|
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
fvec4SIMD();
|
||||
fvec4SIMD(__m128 const & Data);
|
||||
fvec4SIMD(fvec4SIMD const & v);
|
||||
fvec4SIMD(tvec4<float> const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
fvec4SIMD(float const & s);
|
||||
fvec4SIMD(float const & x, float const & y, float const & z, float const & w);
|
||||
fvec4SIMD(float const v[4]);
|
||||
|
||||
////////////////////////////////////////
|
||||
//// Swizzle constructors
|
||||
|
||||
//fvec4SIMD(ref4<float> const & r);
|
||||
|
||||
////////////////////////////////////////
|
||||
//// Convertion vector constructors
|
||||
|
||||
fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
|
||||
fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
|
||||
fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
|
||||
fvec4SIMD(vec3 const & v, float const & s);
|
||||
fvec4SIMD(float const & s, vec3 const & v);
|
||||
fvec4SIMD(vec2 const & v1, vec2 const & v2);
|
||||
//fvec4SIMD(ivec4SIMD const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
fvec4SIMD& operator= (fvec4SIMD const & v);
|
||||
fvec4SIMD& operator+=(fvec4SIMD const & v);
|
||||
fvec4SIMD& operator-=(fvec4SIMD const & v);
|
||||
fvec4SIMD& operator*=(fvec4SIMD const & v);
|
||||
fvec4SIMD& operator/=(fvec4SIMD const & v);
|
||||
|
||||
fvec4SIMD& operator+=(float const & s);
|
||||
fvec4SIMD& operator-=(float const & s);
|
||||
fvec4SIMD& operator*=(float const & s);
|
||||
fvec4SIMD& operator/=(float const & s);
|
||||
|
||||
fvec4SIMD& operator++();
|
||||
fvec4SIMD& operator--();
|
||||
|
||||
////////////////////////////////////////
|
||||
//// Unary bit operators
|
||||
|
||||
//fvec4SIMD& operator%= (float s);
|
||||
//fvec4SIMD& operator%= (fvec4SIMD const & v);
|
||||
//fvec4SIMD& operator&= (float s);
|
||||
//fvec4SIMD& operator&= (fvec4SIMD const & v);
|
||||
//fvec4SIMD& operator|= (float s);
|
||||
//fvec4SIMD& operator|= (fvec4SIMD const & v);
|
||||
//fvec4SIMD& operator^= (float s);
|
||||
//fvec4SIMD& operator^= (fvec4SIMD const & v);
|
||||
//fvec4SIMD& operator<<=(float s);
|
||||
//fvec4SIMD& operator<<=(fvec4SIMD const & v);
|
||||
//fvec4SIMD& operator>>=(float s);
|
||||
//fvec4SIMD& operator>>=(fvec4SIMD const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle operators
|
||||
|
||||
//float swizzle(comp X) const;
|
||||
//vec2 const swizzle(comp X, comp Y) const;
|
||||
//vec3 const swizzle(comp X, comp Y, comp Z) const;
|
||||
//fvec4SIMD const swizzle(comp X, comp Y, comp Z, comp W) const;
|
||||
//fvec4SIMD const swizzle(int X, int Y, int Z, int W) const;
|
||||
//ref4<float> swizzle(comp X, comp Y, comp Z, comp W);
|
||||
};
|
||||
|
||||
}//namespace detail
|
||||
|
||||
namespace gtx{
|
||||
//! GLM_GTX_simd_vec4 extension: SIMD implementation of vec4 type.
|
||||
namespace simd_vec4
|
||||
{
|
||||
typedef detail::fvec4SIMD vec4SIMD;
|
||||
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
||||
#include "simd_vec4.inl"
|
||||
|
||||
namespace glm{using namespace gtx::simd_vec4;}
|
||||
|
||||
#endif//glm_gtx_simd_vec4
|
@ -1,263 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2009-05-07
|
||||
// Updated : 2009-05-07
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/simd_vec4.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
__m128 fvec4SIMD::one = _mm_set_ps1(1.f);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD()
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(__m128 const & Data) :
|
||||
Data(Data)
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) :
|
||||
Data(v.Data)
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(tvec4<float> const & v) :
|
||||
Data(_mm_set_ps(v.w, v.z, v.y, v.x))
|
||||
{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const & s) :
|
||||
Data(_mm_set1_ps(s))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const & x, float const & y, float const & z, float const & w) :
|
||||
// Data(_mm_setr_ps(x, y, z, w))
|
||||
Data(_mm_set_ps(w, z, y, x))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const v[4]) :
|
||||
Data(_mm_load_ps(v))
|
||||
{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
//fvec4SIMD(ref4<float> const & r);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion vector constructors
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) :
|
||||
Data(_mm_set_ps(s2, s1, v.y, v.x))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const & s1, vec2 const & v, float const & s2) :
|
||||
Data(_mm_set_ps(s2, v.y, v.x, s1))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const & s1, float const & s2, vec2 const & v) :
|
||||
Data(_mm_set_ps(v.y, v.x, s2, s1))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(vec3 const & v, float const & s) :
|
||||
Data(_mm_set_ps(s, v.z, v.y, v.x))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(float const & s, vec3 const & v) :
|
||||
Data(_mm_set_ps(v.z, v.y, v.x, s))
|
||||
{}
|
||||
|
||||
inline fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) :
|
||||
Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x))
|
||||
{}
|
||||
|
||||
//inline fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) :
|
||||
// Data(_mm_cvtepi32_ps(v.Data))
|
||||
//{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v)
|
||||
{
|
||||
this->Data = v.Data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator+=(float const & s)
|
||||
{
|
||||
this->Data = _mm_add_ps(Data, _mm_set_ps1(s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator+=(fvec4SIMD const & v)
|
||||
{
|
||||
this->Data = _mm_add_ps(this->Data , v.Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator-=(float const & s)
|
||||
{
|
||||
this->Data = _mm_sub_ps(Data, _mm_set_ps1(s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator-=(fvec4SIMD const & v)
|
||||
{
|
||||
this->Data = _mm_sub_ps(this->Data , v.Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator*=(float const & s)
|
||||
{
|
||||
this->Data = _mm_mul_ps(this->Data, _mm_set_ps1(s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator*=(fvec4SIMD const & v)
|
||||
{
|
||||
this->Data = _mm_mul_ps(this->Data , v.Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator/=(float const & s)
|
||||
{
|
||||
this->Data = _mm_div_ps(Data, _mm_set1_ps(s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator/=(fvec4SIMD const & v)
|
||||
{
|
||||
this->Data = _mm_div_ps(this->Data , v.Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator++()
|
||||
{
|
||||
this->Data = _mm_add_ps(this->Data , glm::detail::one);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline fvec4SIMD& fvec4SIMD::operator--()
|
||||
{
|
||||
this->Data = _mm_sub_ps(this->Data , glm::detail::one);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle operators
|
||||
|
||||
//inline fvec4SIMD const fvec4SIMD::swizzle(int d, int c, int b, int a) const
|
||||
//{
|
||||
// int const Mask = ((d << 6) | (c << 4) | (b << 2) | (a << 0));
|
||||
|
||||
// __m128 Data = _mm_shuffle_ps(this->Data, this->Data, Mask);
|
||||
// return fvec4SIMD(Data);
|
||||
//}
|
||||
|
||||
// operator+
|
||||
inline fvec4SIMD operator+ (fvec4SIMD const & v, float s)
|
||||
{
|
||||
return fvec4SIMD(_mm_add_ps(v.Data, _mm_set1_ps(s)));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator+ (float s, fvec4SIMD const & v)
|
||||
{
|
||||
return fvec4SIMD(_mm_add_ps(_mm_set1_ps(s), v.Data));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator+ (fvec4SIMD const & v1, fvec4SIMD const & v2)
|
||||
{
|
||||
return fvec4SIMD(_mm_add_ps(v1.Data, v2.Data));
|
||||
}
|
||||
|
||||
//operator-
|
||||
inline fvec4SIMD operator- (fvec4SIMD const & v, float s)
|
||||
{
|
||||
return fvec4SIMD(_mm_sub_ps(v.Data, _mm_set1_ps(s)));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator- (float s, fvec4SIMD const & v)
|
||||
{
|
||||
return fvec4SIMD(_mm_sub_ps(_mm_set1_ps(s), v.Data));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator- (fvec4SIMD const & v1, fvec4SIMD const & v2)
|
||||
{
|
||||
return fvec4SIMD(_mm_sub_ps(v1.Data, v2.Data));
|
||||
}
|
||||
|
||||
//operator*
|
||||
inline fvec4SIMD operator* (fvec4SIMD const & v, float s)
|
||||
{
|
||||
__m128 par0 = v.Data;
|
||||
__m128 par1 = _mm_set1_ps(s);
|
||||
return fvec4SIMD(_mm_mul_ps(par0, par1));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator* (float s, fvec4SIMD const & v)
|
||||
{
|
||||
__m128 par0 = _mm_set1_ps(s);
|
||||
__m128 par1 = v.Data;
|
||||
return fvec4SIMD(_mm_mul_ps(par0, par1));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator* (fvec4SIMD const & v1, fvec4SIMD const & v2)
|
||||
{
|
||||
return fvec4SIMD(_mm_mul_ps(v1.Data, v2.Data));
|
||||
}
|
||||
|
||||
//operator/
|
||||
inline fvec4SIMD operator/ (fvec4SIMD const & v, float s)
|
||||
{
|
||||
__m128 par0 = v.Data;
|
||||
__m128 par1 = _mm_set1_ps(s);
|
||||
return fvec4SIMD(_mm_div_ps(par0, par1));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator/ (float s, fvec4SIMD const & v)
|
||||
{
|
||||
__m128 par0 = _mm_set1_ps(s);
|
||||
__m128 par1 = v.Data;
|
||||
return fvec4SIMD(_mm_div_ps(par0, par1));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator/ (fvec4SIMD const & v1, fvec4SIMD const & v2)
|
||||
{
|
||||
return fvec4SIMD(_mm_div_ps(v1.Data, v2.Data));
|
||||
}
|
||||
|
||||
// Unary constant operators
|
||||
inline fvec4SIMD operator- (fvec4SIMD const & v)
|
||||
{
|
||||
return fvec4SIMD(_mm_sub_ps(_mm_setzero_ps(), v.Data));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator++ (fvec4SIMD const & v, int)
|
||||
{
|
||||
return fvec4SIMD(_mm_add_ps(v.Data, glm::detail::one));
|
||||
}
|
||||
|
||||
inline fvec4SIMD operator-- (fvec4SIMD const & v, int)
|
||||
{
|
||||
return fvec4SIMD(_mm_sub_ps(v.Data, glm::detail::one));
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
namespace gtx{
|
||||
namespace simd_vec4
|
||||
{
|
||||
|
||||
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
Loading…
Reference in New Issue
Block a user