diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-23 15:09:27 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-23 15:09:27 +0300 |
commit | 2aa4b6045a1d249025bb8eb2f19fcc72d0739341 (patch) | |
tree | 913ca3e5207daa420febb572793011cbc30ed955 /intern/cycles/render/graph.cpp | |
parent | 6894bb055554b8db0af1fcfdec6e3fa5f088e777 (diff) |
Cycles: Fix wrong closure counter in feature adaptive kernel
Some closures were missing from calculation, leading to an array
under-allocation, presumable causing memory corruption issues with
emission shaders on OpenCL and was causing issues with Volume 3D
textures with CUDA.
The issue was identified by Thomas Dinges, the patch is different
from the original D2006. See the brief discussion there. Current
approach is similar (or the same) as Brecht suggested.
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r-- | intern/cycles/render/graph.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 15c89cc4b51..24e4c9f33d5 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -984,17 +984,18 @@ int ShaderGraph::get_num_closures() { int num_closures = 0; foreach(ShaderNode *node, nodes) { - if(node->special_type == SHADER_SPECIAL_TYPE_CLOSURE) { - BsdfNode *bsdf_node = static_cast<BsdfNode*>(node); - /* TODO(sergey): Make it more generic approach, maybe some utility - * macros like CLOSURE_IS_FOO()? - */ - if(CLOSURE_IS_BSSRDF(bsdf_node->closure)) - num_closures = num_closures + 3; - else if(CLOSURE_IS_GLASS(bsdf_node->closure)) - num_closures = num_closures + 2; - else - num_closures = num_closures + 1; + ClosureType closure_type = node->get_closure_type(); + if(closure_type == CLOSURE_NONE_ID) { + continue; + } + else if(CLOSURE_IS_BSSRDF(closure_type)) { + num_closures += 3; + } + else if(CLOSURE_IS_GLASS(closure_type)) { + num_closures += 2; + } + else { + ++num_closures; } } return num_closures; |