diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2014-01-11 22:20:03 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2014-01-11 22:20:03 +0400 |
commit | da3fdf0b4bcded2a9473279078602ac24369472a (patch) | |
tree | 54f11dc459ac645e188faa8d73635c4ba9030fb0 /intern/cycles/util/util_simd.h | |
parent | b886c26d1f70d512b4f68975142372e3bee81c89 (diff) |
Code Cleanup: in Cycles SSE replace macros with templates, skip unused code with preprocessor, simplify casts
Diffstat (limited to 'intern/cycles/util/util_simd.h')
-rw-r--r-- | intern/cycles/util/util_simd.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index 02e2880212e..a6880e77054 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -92,6 +92,22 @@ ccl_device_inline const __m128 blend(const __m128& mask, const __m128& a, const } #endif +/* calculate a*b+c (replacement for fused multiply-add on SSE CPUs) */ +ccl_device_inline const __m128 fma(const __m128& a, const __m128& b, const __m128& c) +{ + return _mm_add_ps(_mm_mul_ps(a, b), c); +} + +template<size_t N> ccl_device_inline const __m128 broadcast(const __m128& a) +{ + return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(a), _MM_SHUFFLE(N, N, N, N))); +} + +template<size_t N> ccl_device_inline const __m128i broadcast(const __m128i& a) +{ + return _mm_shuffle_epi32(a, _MM_SHUFFLE(N, N, N, N)); +} + #endif /* __KERNEL_SSE2__ */ CCL_NAMESPACE_END |