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
This commit is contained in:
Sergey Sharybin
2015-04-28 00:13:03 +05:00
parent 278ff15c7f
commit ae7d84dbc1
19 changed files with 52 additions and 43 deletions

View File

@@ -102,7 +102,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
float mist_inv_depth = kernel_data.film.mist_inv_depth;
float depth = camera_distance(kg, sd->P);
float mist = clamp((depth - mist_start)*mist_inv_depth, 0.0f, 1.0f);
float mist = saturate((depth - mist_start)*mist_inv_depth);
/* falloff */
float mist_falloff = kernel_data.film.mist_falloff;