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:
@@ -3752,7 +3752,7 @@ void MathNode::compile(SVMCompiler& compiler)
|
||||
value1_in->value.x,
|
||||
value2_in->value.x);
|
||||
if(use_clamp) {
|
||||
optimized_value = clamp(optimized_value, 0.0f, 1.0f);
|
||||
optimized_value = saturate(optimized_value);
|
||||
}
|
||||
compiler.add_node(NODE_VALUE_F,
|
||||
__float_as_int(optimized_value),
|
||||
|
Reference in New Issue
Block a user