minor optimization.

pull/216/head
castano 14 years ago
parent 73851ab86f
commit d8ed531e4c

@ -109,7 +109,7 @@ void ClusterFit::SetMetric(float r, float g, float b)
float ClusterFit::GetBestError() const
{
#if SQUISH_USE_SIMD
return m_besterror.GetVec3().X();
return m_besterror.GetX();
#else
return m_besterror;
#endif

@ -72,6 +72,13 @@ public:
_mm_store_ps( c, m_v );
return Vec3( c[0], c[1], c[2] );
}
float GetX() const
{
SQUISH_ALIGN_16 float f;
_mm_store_ss(&f, m_v);
return f;
}
Vec4 SplatX() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 0 ) ) ); }
Vec4 SplatY() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 1 ) ) ); }

@ -78,7 +78,14 @@ public:
u.v = m_v;
return Vec3( u.c[0], u.c[1], u.c[2] );
}
float GetX() const
{
union { vector float v; float c[4]; } u;
u.v = m_v;
return u.c[0];
}
Vec4 SplatX() const { return Vec4( vec_splat( m_v, 0 ) ); }
Vec4 SplatY() const { return Vec4( vec_splat( m_v, 1 ) ); }
Vec4 SplatZ() const { return Vec4( vec_splat( m_v, 2 ) ); }

@ -120,7 +120,7 @@ float WeightedClusterFit::GetBestError() const
#if SQUISH_USE_SIMD
Vec4 x = m_xxsum * m_metricSqr;
Vec4 error = m_besterror + x.SplatX() + x.SplatY() + x.SplatZ();
return error.GetVec3().X();
return error.GetX();
#else
return m_besterror + Dot(m_xxsum, m_metricSqr);
#endif

Loading…
Cancel
Save