mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 02:04:35 +00:00
Fixed simd mat4 build
This commit is contained in:
parent
866db89305
commit
4634ff3647
@ -11,9 +11,7 @@
|
|||||||
#define GLM_DETAIL_INTRINSIC_MATRIX_INCLUDED
|
#define GLM_DETAIL_INTRINSIC_MATRIX_INCLUDED
|
||||||
|
|
||||||
#include "../glm.hpp"
|
#include "../glm.hpp"
|
||||||
|
#include "intrinsic_geometric.hpp"
|
||||||
#include <xmmintrin.h>
|
|
||||||
#include <emmintrin.h>
|
|
||||||
|
|
||||||
void _mm_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]);
|
void _mm_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]);
|
||||||
|
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
// Dependency:
|
// Dependency:
|
||||||
#include "../glm.hpp"
|
#include "../glm.hpp"
|
||||||
|
#include "../core/intrinsic_matrix.hpp"
|
||||||
#include "../gtx/simd_vec4.hpp"
|
#include "../gtx/simd_vec4.hpp"
|
||||||
#include <xmmintrin.h>
|
|
||||||
#include <emmintrin.h>
|
|
||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
@ -26,23 +25,18 @@ namespace glm
|
|||||||
{
|
{
|
||||||
GLM_ALIGNED(struct, 16) fmat4x4SIMD
|
GLM_ALIGNED(struct, 16) fmat4x4SIMD
|
||||||
{
|
{
|
||||||
static __m128 one;
|
enum ctor{null};
|
||||||
|
|
||||||
enum no_init
|
|
||||||
{
|
|
||||||
NO_INIT
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef float value_type;
|
typedef float value_type;
|
||||||
typedef fvec4SIMD col_type;
|
typedef fvec4SIMD col_type;
|
||||||
typedef fvec4SIMD row_type;
|
typedef fvec4SIMD row_type;
|
||||||
typedef glm::sizeType size_type;
|
typedef std::size_t size_type;
|
||||||
static size_type value_size();
|
static size_type value_size();
|
||||||
static size_type col_size();
|
static size_type col_size();
|
||||||
static size_type row_size();
|
static size_type row_size();
|
||||||
static bool is_matrix();
|
static bool is_matrix();
|
||||||
|
|
||||||
fvec4SIMD value[4];
|
fvec4SIMD Data[4];
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -60,7 +54,7 @@ namespace glm
|
|||||||
fvec4SIMD const & v2,
|
fvec4SIMD const & v2,
|
||||||
fvec4SIMD const & v3);
|
fvec4SIMD const & v3);
|
||||||
explicit fmat4x4SIMD(
|
explicit fmat4x4SIMD(
|
||||||
tmat4x4 const & m);
|
tmat4x4<float> const & m);
|
||||||
|
|
||||||
// Conversions
|
// Conversions
|
||||||
//template <typename U>
|
//template <typename U>
|
||||||
@ -129,7 +123,7 @@ namespace glm
|
|||||||
//! GLM_GTX_simd_mat4 extension: SIMD implementation of vec4 type.
|
//! GLM_GTX_simd_mat4 extension: SIMD implementation of vec4 type.
|
||||||
namespace simd_mat4
|
namespace simd_mat4
|
||||||
{
|
{
|
||||||
typedef detail::fmat4SIMD mat4SIMD;
|
typedef detail::fmat4x4SIMD simd_mat4;
|
||||||
|
|
||||||
}//namespace simd_mat4
|
}//namespace simd_mat4
|
||||||
}//namespace gtx
|
}//namespace gtx
|
||||||
|
@ -15,10 +15,10 @@ namespace detail
|
|||||||
|
|
||||||
inline fmat4x4SIMD::fmat4x4SIMD(float const & s)
|
inline fmat4x4SIMD::fmat4x4SIMD(float const & s)
|
||||||
{
|
{
|
||||||
this->value[0] = fvec4SIMD(s, 0, 0, 0);
|
this->Data[0] = fvec4SIMD(s, 0, 0, 0);
|
||||||
this->value[1] = fvec4SIMD(0, s, 0, 0);
|
this->Data[1] = fvec4SIMD(0, s, 0, 0);
|
||||||
this->value[2] = fvec4SIMD(0, 0, s, 0);
|
this->Data[2] = fvec4SIMD(0, 0, s, 0);
|
||||||
this->value[3] = fvec4SIMD(0, 0, 0, s);
|
this->Data[3] = fvec4SIMD(0, 0, 0, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fmat4x4SIMD::fmat4x4SIMD
|
inline fmat4x4SIMD::fmat4x4SIMD
|
||||||
@ -29,10 +29,10 @@ namespace detail
|
|||||||
float const & x3, float const & y3, float const & z3, float const & w3
|
float const & x3, float const & y3, float const & z3, float const & w3
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0] = fvec4SIMD(x0, y0, z0, w0);
|
this->Data[0] = fvec4SIMD(x0, y0, z0, w0);
|
||||||
this->value[1] = fvec4SIMD(x1, y1, z1, w1);
|
this->Data[1] = fvec4SIMD(x1, y1, z1, w1);
|
||||||
this->value[2] = fvec4SIMD(x2, y2, z2, w2);
|
this->Data[2] = fvec4SIMD(x2, y2, z2, w2);
|
||||||
this->value[3] = fvec4SIMD(x3, y3, z3, w3);
|
this->Data[3] = fvec4SIMD(x3, y3, z3, w3);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fmat4x4SIMD::fmat4x4SIMD
|
inline fmat4x4SIMD::fmat4x4SIMD
|
||||||
@ -43,21 +43,21 @@ namespace detail
|
|||||||
fvec4SIMD const & v3
|
fvec4SIMD const & v3
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0] = v0;
|
this->Data[0] = v0;
|
||||||
this->value[1] = v1;
|
this->Data[1] = v1;
|
||||||
this->value[2] = v2;
|
this->Data[2] = v2;
|
||||||
this->value[3] = v3;
|
this->Data[3] = v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fmat4x4SIMD::fmat4x4SIMD
|
inline fmat4x4SIMD::fmat4x4SIMD
|
||||||
(
|
(
|
||||||
tmat4x4 const & m
|
tmat4x4<float> const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0] = fvec4SIMD(m[0]);
|
this->Data[0] = fvec4SIMD(m[0]);
|
||||||
this->value[1] = fvec4SIMD(m[1]);
|
this->Data[1] = fvec4SIMD(m[1]);
|
||||||
this->value[2] = fvec4SIMD(m[2]);
|
this->Data[2] = fvec4SIMD(m[2]);
|
||||||
this->value[3] = fvec4SIMD(m[3]);
|
this->Data[3] = fvec4SIMD(m[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
@ -65,26 +65,26 @@ namespace detail
|
|||||||
|
|
||||||
inline fvec4SIMD & fmat4x4SIMD::operator[]
|
inline fvec4SIMD & fmat4x4SIMD::operator[]
|
||||||
(
|
(
|
||||||
typename fmat4x4SIMD::size_type i
|
fmat4x4SIMD::size_type i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert(
|
assert(
|
||||||
i >= typename tmat4x4<valType>::size_type(0) &&
|
i >= fmat4x4SIMD::size_type(0) &&
|
||||||
i < tmat4x4<valType>::col_size());
|
i < fmat4x4SIMD::col_size());
|
||||||
|
|
||||||
return value[i];
|
return this->Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fvec4SIMD const & fmat4x4SIMD::operator[]
|
inline fvec4SIMD const & fmat4x4SIMD::operator[]
|
||||||
(
|
(
|
||||||
typename fmat4x4SIMD::size_type i
|
fmat4x4SIMD::size_type i
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
assert(
|
assert(
|
||||||
i >= typename fmat4x4SIMD::size_type(0) &&
|
i >= fmat4x4SIMD::size_type(0) &&
|
||||||
i < fmat4x4SIMD::col_size());
|
i < fmat4x4SIMD::col_size());
|
||||||
|
|
||||||
return value[i];
|
return this->Data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
@ -95,10 +95,10 @@ namespace detail
|
|||||||
fmat4x4SIMD const & m
|
fmat4x4SIMD const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0].Data = m[0].Data;
|
this->Data[0] = m[0];
|
||||||
this->value[1].Data = m[1].Data;
|
this->Data[1] = m[1];
|
||||||
this->value[2].Data = m[2].Data;
|
this->Data[2] = m[2];
|
||||||
this->value[3].Data = m[3].Data;
|
this->Data[3] = m[3];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,10 +107,10 @@ namespace detail
|
|||||||
fmat4x4SIMD const & m
|
fmat4x4SIMD const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, m[0].Data);
|
this->Data[0].Data = _mm_add_ps(this->Data[0].Data, m[0].Data);
|
||||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, m[1].Data);
|
this->Data[1].Data = _mm_add_ps(this->Data[1].Data, m[1].Data);
|
||||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, m[2].Data);
|
this->Data[2].Data = _mm_add_ps(this->Data[2].Data, m[2].Data);
|
||||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, m[3].Data);
|
this->Data[3].Data = _mm_add_ps(this->Data[3].Data, m[3].Data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +119,10 @@ namespace detail
|
|||||||
fmat4x4SIMD const & m
|
fmat4x4SIMD const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, m[0].Data);
|
this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, m[0].Data);
|
||||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, m[1].Data);
|
this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, m[1].Data);
|
||||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, m[2].Data);
|
this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, m[2].Data);
|
||||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, m[3].Data);
|
this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, m[3].Data);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ namespace detail
|
|||||||
fmat4x4SIMD const & m
|
fmat4x4SIMD const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_mm_mul_ps(this->Data, m.Data, this->Data);
|
_mm_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ namespace detail
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
__m128 Inv[4];
|
__m128 Inv[4];
|
||||||
_mm_inverse_ps(m.Data, Inv);
|
_mm_inverse_ps(&this->Data[0].Data, Inv);
|
||||||
_mm_mul_ps(this->Data, Inv, this->Data);
|
_mm_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,10 +153,10 @@ namespace detail
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
__m128 Operand = _mm_set_ps1(s);
|
__m128 Operand = _mm_set_ps1(s);
|
||||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, Operand);
|
this->Data[0].Data = _mm_add_ps(this->Data[0].Data, Operand);
|
||||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, Operand);
|
this->Data[1].Data = _mm_add_ps(this->Data[1].Data, Operand);
|
||||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, Operand);
|
this->Data[2].Data = _mm_add_ps(this->Data[2].Data, Operand);
|
||||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, Operand);
|
this->Data[3].Data = _mm_add_ps(this->Data[3].Data, Operand);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,10 +166,10 @@ namespace detail
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
__m128 Operand = _mm_set_ps1(s);
|
__m128 Operand = _mm_set_ps1(s);
|
||||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, Operand);
|
this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, Operand);
|
||||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, Operand);
|
this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, Operand);
|
||||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, Operand);
|
this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, Operand);
|
||||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, Operand);
|
this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, Operand);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,10 +179,10 @@ namespace detail
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
__m128 Operand = _mm_set_ps1(s);
|
__m128 Operand = _mm_set_ps1(s);
|
||||||
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
|
this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand);
|
||||||
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
|
this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand);
|
||||||
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
|
this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand);
|
||||||
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
|
this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,29 +191,29 @@ namespace detail
|
|||||||
float const & s
|
float const & s
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
__m128 Operand = _mm_div_ps(one, s));
|
__m128 Operand = _mm_div_ps(one, _mm_set_ps1(s));
|
||||||
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
|
this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand);
|
||||||
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
|
this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand);
|
||||||
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
|
this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand);
|
||||||
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
|
this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fmat4x4SIMD & fmat4x4SIMD::operator++ ()
|
inline fmat4x4SIMD & fmat4x4SIMD::operator++ ()
|
||||||
{
|
{
|
||||||
this->value[0].Data = _mm_add_ps(this->value[0].Data, one);
|
this->Data[0].Data = _mm_add_ps(this->Data[0].Data, one);
|
||||||
this->value[1].Data = _mm_add_ps(this->value[1].Data, one);
|
this->Data[1].Data = _mm_add_ps(this->Data[1].Data, one);
|
||||||
this->value[2].Data = _mm_add_ps(this->value[2].Data, one);
|
this->Data[2].Data = _mm_add_ps(this->Data[2].Data, one);
|
||||||
this->value[3].Data = _mm_add_ps(this->value[3].Data, one);
|
this->Data[3].Data = _mm_add_ps(this->Data[3].Data, one);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fmat4x4SIMD & fmat4x4SIMD::operator-- ()
|
inline fmat4x4SIMD & fmat4x4SIMD::operator-- ()
|
||||||
{
|
{
|
||||||
this->value[0].Data = _mm_sub_ps(this->value[0].Data, one);
|
this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, one);
|
||||||
this->value[1].Data = _mm_sub_ps(this->value[1].Data, one);
|
this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, one);
|
||||||
this->value[2].Data = _mm_sub_ps(this->value[2].Data, one);
|
this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, one);
|
||||||
this->value[3].Data = _mm_sub_ps(this->value[3].Data, one);
|
this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, one);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,9 +156,7 @@ namespace glm
|
|||||||
template <comp a, comp b, comp c, comp d>
|
template <comp a, comp b, comp c, comp d>
|
||||||
inline fvec4SIMD fvec4SIMD::swizzle() const
|
inline fvec4SIMD fvec4SIMD::swizzle() const
|
||||||
{
|
{
|
||||||
int const Mask = ((int(d) << 6) | (int(c) << 4) | (int(b) << 2) | (int(a) << 0));
|
__m128 Data = _mm_shuffle_ps(this->Data, this->Data, ((int(d) << 6) | (int(c) << 4) | (int(b) << 2) | (int(a) << 0)));
|
||||||
|
|
||||||
__m128 Data = _mm_shuffle_ps(this->Data, this->Data, Mask);
|
|
||||||
return fvec4SIMD(Data);
|
return fvec4SIMD(Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user