Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-04-27 22:13:03 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-04-27 22:38:32 +0300
commitae7d84dbc1936ef7ddd00f9c22d074389f97f04f (patch)
tree7103596bc78785ed769e90c1570d654cc14a839d /intern/cycles/render
parent278ff15c7f3c4a91ba049b7a13ecf8a4183ebf67 (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/render')
-rw-r--r--intern/cycles/render/buffers.cpp4
-rw-r--r--intern/cycles/render/nodes.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 5202bf5862c..dc00da1bf88 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -187,7 +187,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
else if(type == PASS_MIST) {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
- pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f);
+ pixels[0] = saturate(f*scale_exposure);
}
}
#ifdef WITH_CYCLES_DEBUG
@@ -298,7 +298,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[2] = f.z*scale_exposure;
/* clamp since alpha might be > 1.0 due to russian roulette */
- pixels[3] = clamp(f.w*scale, 0.0f, 1.0f);
+ pixels[3] = saturate(f.w*scale);
}
}
}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 747bafcc904..8529855ff2e 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -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),