From 2aa4b6045a1d249025bb8eb2f19fcc72d0739341 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 May 2016 14:09:27 +0200 Subject: 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. --- intern/cycles/render/graph.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'intern/cycles/render/graph.cpp') 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(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; -- cgit v1.2.3