diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2014-04-03 23:34:53 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2014-04-03 23:35:10 +0400 |
commit | ab32a1807dd153723d26a7d53895ed071233dafc (patch) | |
tree | f4e27eac2ecab3353ff558f346c1be1ad780c41f /intern/cycles/util/util_simd.h | |
parent | c019ae5ea3a8eb49010de76c14a359c4729bbcf0 (diff) |
Cycles: SSE optimization for Voronoi cells texture
Gives 5-6% speedup for Caterpillar_PatazStudio.blend.
Reviewed By: brecht, dingto
Differential Revision: https://developer.blender.org/D419
Diffstat (limited to 'intern/cycles/util/util_simd.h')
-rw-r--r-- | intern/cycles/util/util_simd.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index 486816cc5c0..679556ee59b 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -220,6 +220,18 @@ ccl_device_inline const __m128 dot3_splat(const __m128& a, const __m128& b) #endif } +/* squared length taking only specified axes into account */ +template<size_t X, size_t Y, size_t Z, size_t W> +ccl_device_inline float len_squared(const __m128& a) +{ +#ifndef __KERNEL_SSE41__ + float4& t = (float4 &)a; + return (X ? t.x * t.x : 0.0f) + (Y ? t.y * t.y : 0.0f) + (Z ? t.z * t.z : 0.0f) + (W ? t.w * t.w : 0.0f); +#else + return _mm_cvtss_f32(_mm_dp_ps(a, a, (X << 4) | (Y << 5) | (Z << 6) | (W << 7) | 0xf)); +#endif +} + ccl_device_inline float dot3(const __m128& a, const __m128& b) { #ifdef __KERNEL_SSE41__ |