Stop using some fast approx when ISA_INVARIANCE=ON
@@ -433,8 +433,11 @@ ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)
return vint4(_mm_mullo_epi32 (a.m, b.m));
#else
__m128i t1 = _mm_mul_epu32(a.m, b.m);
- __m128i t2 = _mm_mul_epu32(_mm_srli_si128(a.m, 4), _mm_srli_si128(b.m, 4));
- __m128i r = _mm_unpacklo_epi32(_mm_shuffle_epi32(t1, _MM_SHUFFLE (0, 0, 2, 0)),
+ __m128i t2 = _mm_mul_epu32(
+ _mm_srli_si128(a.m, 4),
+ _mm_srli_si128(b.m, 4));
+ __m128i r = _mm_unpacklo_epi32(
+ _mm_shuffle_epi32(t1, _MM_SHUFFLE (0, 0, 2, 0)),
_mm_shuffle_epi32(t2, _MM_SHUFFLE (0, 0, 2, 0)));
return vint4(r);
#endif
@@ -1039,10 +1042,14 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)
*/
ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)
{
+#if ASTCENC_ISA_INVARIANCE == 0
// Reciprocal with a single NR iteration
__m128 t1 = _mm_rcp_ps(b.m);
__m128 t2 = _mm_mul_ps(b.m, _mm_mul_ps(t1, t1));
return vfloat4(_mm_sub_ps(_mm_add_ps(t1, t1), t2));
+#else
+ return 1.0f / b;
+#endif
}
/**
@@ -1050,8 +1057,12 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)
*/
ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)
{
+#if ASTCENC_ISA_INVARIANCE == 0
// Reciprocal with no NR iteration
return vfloat4(_mm_rcp_ps(b.m));
+#else
+ return 1.0f / b;
+#endif
}
/**
@@ -1059,19 +1070,23 @@ ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)
*/
ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)
{
+#if ASTCENC_ISA_INVARIANCE == 0
// Compute 1/divisor using rsqrt with one NR iteration
- vfloat4 half = vfloat4(0.5f);
- vfloat4 three = vfloat4(3.0f);
vfloat4 length = dot(a, a);
-
__m128 raw = _mm_rsqrt_ps(length.m);
// Apply NR iteration
+ vfloat4 half = vfloat4(0.5f);
+ vfloat4 three = vfloat4(3.0f);
__m128 ref = _mm_mul_ps(_mm_mul_ps(length.m, raw), raw);
ref = _mm_mul_ps(_mm_mul_ps(half.m, raw), _mm_sub_ps(three.m, ref));
// Apply scaling factor
return vfloat4(_mm_mul_ps(a.m, ref));
+#else
+ vfloat4 length = dot(a, a);
+ return a / sqrt(length);
+#endif
}
/**
