Fixed build fixed SSE fast det

This commit is contained in:
Christophe Riccio 2011-01-11 01:41:02 +00:00
parent 178f736fb0
commit 197c0d26b7
4 changed files with 38 additions and 36 deletions

View File

@ -421,23 +421,23 @@ inline __m128 sse_det_ps
//T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
// First 2 columns
__m128 Swp2A = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(0, 1, 1, 2));
__m128 Swp3A = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(3, 2, 3, 3));
__m128 Swp2A = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(0, 1, 1, 2));
__m128 Swp3A = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(3, 2, 3, 3));
__m128 MulA = _mm_mul_ps(Swp2A, Swp3A);
// Second 2 columns
__m128 Swp2B = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(0, 1, 1, 2));
__m128 Swp3B = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(3, 2, 3, 3));
__m128 MulB = _mm_mul_ps(Swp2A, Swp3A);
__m128 Swp2B = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(3, 2, 3, 3));
__m128 Swp3B = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(0, 1, 1, 2));
__m128 MulB = _mm_mul_ps(Swp2B, Swp3B);
// Columns subtraction
__m128 SubAB = _mm_sub_ps(MulA, MulB);
__m128 SubE = _mm_sub_ps(MulA, MulB);
// Last 2 rows
__m128 Swp2C = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(1, 2, 0, 0));
__m128 Swp3C = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(0, 0, 1, 2));
__m128 Swp2C = _mm_shuffle_ps(m[2], m[2], _MM_SHUFFLE(0, 0, 1, 2));
__m128 Swp3C = _mm_shuffle_ps(m[3], m[3], _MM_SHUFFLE(1, 2, 0, 0));
__m128 MulC = _mm_mul_ps(Swp2C, Swp3C);
__m128 SwpD = __mm_hl_ps(MulC);
__m128 SubF = _mm_sub_ps(_mm_movehl_ps(MulC, MulC), MulC);
//detail::tvec4<T> DetCof(
// + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02),
@ -445,29 +445,31 @@ inline __m128 sse_det_ps
// + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05),
// - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05));
__128 SubFacA = _mm_shuffle_ps(SubAB, SubAB, _MM_SHUFFLE(2, 1, 0, 0));
__128 SwpFacA = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(0, 0, 0, 1));
__128 MulFacA = __mm_mul_ps(SwpFacA, SubFacA);
__m128 SubFacA = _mm_shuffle_ps(SubE, SubE, _MM_SHUFFLE(2, 1, 0, 0));
__m128 SwpFacA = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(0, 0, 0, 1));
__m128 MulFacA = _mm_mul_ps(SwpFacA, SubFacA);
__128 SubFacB = ;
__128 SwpFacB = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(1, 1, 2, 2));
__128 MulFacB = __mm_mul_ps(SwpFacB, SubFacB);
__m128 SubTmpB = _mm_shuffle_ps(SubE, SubF, _MM_SHUFFLE(0, 0, 3, 1));
__m128 SubFacB = _mm_shuffle_ps(SubTmpB, SubTmpB, _MM_SHUFFLE(3, 1, 1, 0));//SubF[0], SubE[3], SubE[3], SubE[1];
__m128 SwpFacB = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(1, 1, 2, 2));
__m128 MulFacB = _mm_mul_ps(SwpFacB, SubFacB);
__128 SubRes = __mm_sub_ps(MulFacA, MulFacA);
__m128 SubRes = _mm_sub_ps(MulFacA, MulFacB);
__128 SubFacC = ;
__128 SwpFacC = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(1, 1, 2, 2));
__128 MulFacC = __mm_mul_ps(SwpFacC, SubFacC);
__m128 SubTmpC = _mm_shuffle_ps(SubE, SubF, _MM_SHUFFLE(1, 0, 2, 2));
__m128 SubFacC = _mm_shuffle_ps(SubTmpC, SubTmpC, _MM_SHUFFLE(3, 3, 2, 0));
__m128 SwpFacC = _mm_shuffle_ps(m[1], m[1], _MM_SHUFFLE(2, 3, 3, 3));
__m128 MulFacC = _mm_mul_ps(SwpFacC, SubFacC);
__m128 AddRes = __mm_add_ps(SubRes, MulFacC);
__m128 DetCof = __mm_mul_ps(AddRes, _mm_set_ps( 1.0f,-1.0f, 1.0f,-1.0f));
__m128 AddRes = _mm_add_ps(SubRes, MulFacC);
__m128 DetCof = _mm_mul_ps(AddRes, _mm_setr_ps( 1.0f,-1.0f, 1.0f,-1.0f));
//return m[0][0] * DetCof[0]
// + m[0][1] * DetCof[1]
// + m[0][2] * DetCof[2]
// + m[0][3] * DetCof[3];
return sse_dot_ps(m[0], Signed);
return sse_dot_ps(m[0], DetCof);
}
inline void sse_inverse_ps(__m128 const in[4], __m128 out[4])
@ -692,7 +694,7 @@ inline void sse_inverse_ps(__m128 const in[4], __m128 out[4])
// + m[0][1] * Inverse[1][0]
// + m[0][2] * Inverse[2][0]
// + m[0][3] * Inverse[3][0];
__m128 Det0 = _mm_dot_ps(in[0], Row2);
__m128 Det0 = sse_dot_ps(in[0], Row2);
__m128 Rcp0 = _mm_div_ps(one, Det0);
//__m128 Rcp0 = _mm_rcp_ps(Det0);
@ -1008,10 +1010,10 @@ void sse_rotate_ps(__m128 const in[4], float Angle, float const v[3], __m128 out
void sse_outer_ps(__m128 const & c, __m128 const & r, __m128 out[4])
{
out[0] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(0, 0, 0, 0));
out[1] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(1, 1, 1, 1));
out[2] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(2, 2, 2, 2));
out[3] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(3, 3, 3, 3));
out[0] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(0, 0, 0, 0)));
out[1] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(1, 1, 1, 1)));
out[2] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(2, 2, 2, 2)));
out[3] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(3, 3, 3, 3)));
}
}//namespace detail

View File

@ -132,7 +132,7 @@ namespace detail
fmat4x4SIMD const & m
)
{
_mm_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data);
sse_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data);
return *this;
}
@ -142,8 +142,8 @@ namespace detail
)
{
__m128 Inv[4];
_mm_inverse_ps(&this->Data[0].Data, Inv);
_mm_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data);
sse_inverse_ps(&this->Data[0].Data, Inv);
sse_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data);
return *this;
}
@ -234,7 +234,7 @@ namespace simd_mat4
inline detail::fmat4x4SIMD simd_transpose(detail::fmat4x4SIMD const & m)
{
detail::fmat4x4SIMD result;
sse_transpose_ps(&m[0].Data, &result[0].Data);
detail::sse_transpose_ps(&m[0].Data, &result[0].Data);
return result;
}
@ -246,7 +246,7 @@ namespace simd_mat4
inline detail::fmat4x4SIMD simd_inverse(detail::fmat4x4SIMD const & m)
{
detail::fmat4x4SIMD result;
sse_inverse_ps(&m[0].Data, &result[0].Data);
detail::sse_inverse_ps(&m[0].Data, &result[0].Data);
return result;
}
}//namespace simd_mat4

View File

@ -273,7 +273,7 @@ namespace glm
detail::fvec4SIMD const & b
)
{
return _mm_xpd_ps(a.Data, b.Data);
return detail::sse_xpd_ps(a.Data, b.Data);
}
# else//(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_PURE)
inline detail::fvec4SIMD cross
@ -282,7 +282,7 @@ namespace glm
detail::fvec4SIMD const & b
)
{
return glm::cross(a, b);
return detail::sse_xpd_ps(a.Data, b.Data);
}
# endif
}//namespace simd_vec4

View File

@ -30,8 +30,8 @@ int main(int argc, void* argv[])
glm::simd_vec4(0.5f, 3.0f, 0.6f, 0.02f),
glm::simd_vec4(0.2f, 0.4f, 2.0f, 0.03f),
glm::simd_vec4(4.0f, 3.0f, 2.0f, 1.00f));
__m128 DetB = sse_slow_det_ps(&IdentityB.Data[0].Data);
__m128 DetC = sse_det_ps(&IdentityB.Data[0].Data);
__m128 DetB = glm::detail::sse_slow_det_ps(&IdentityB.Data[0].Data);
__m128 DetC = glm::detail::sse_det_ps(&IdentityB.Data[0].Data);
return 0;
}