diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-27 22:13:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-27 22:38:32 +0300 |
commit | ae7d84dbc1936ef7ddd00f9c22d074389f97f04f (patch) | |
tree | 7103596bc78785ed769e90c1570d654cc14a839d /intern/cycles/util | |
parent | 278ff15c7f3c4a91ba049b7a13ecf8a4183ebf67 (diff) |
Cycles: Use native saturate function for CUDA
This more a workaround for CUDA optimizer which can't optimize clamp(x, 0, 1)
into a single instruction and uses 4 instructions instead.
Original patch by @lockal with own modification:
Don't make changes outside of the kernel. They don't make any difference
anyway and term saturate() has a bit different meaning outside of kernel.
This gives around 2% of speedup in Barcelona file, but in more complex shader
setups with lots of math nodes with clamping speedup could be much nicer.
Subscribers: dingto
Projects: #cycles
Differential Revision: https://developer.blender.org/D1224
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_math.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 6208608a233..f48625ec95d 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -175,6 +175,15 @@ ccl_device_inline float clamp(float a, float mn, float mx) #endif +#ifndef __KERNEL_CUDA__ + +ccl_device_inline float saturate(float a) +{ + return clamp(a, 0.0f, 1.0f); +} + +#endif + ccl_device_inline int float_to_int(float f) { return (int)f; |