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>2017-03-31 16:29:20 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-03-31 18:08:18 +0300
commit90df1142a35dd9b738ef21ceb5f3b12249846482 (patch)
tree2f920b4eb84244bd0c83c4ae100fc9ae35868d32 /intern/cycles/blender/blender_shader.cpp
parent27d20a04b54e334784eeb0ec8d440fd6707d9fa3 (diff)
Cycles: Solve threading conflict in shader synchronization
Update tag might access links (when checking for attributes) and the links might be in the middle of rebuild in simplification logic.
Diffstat (limited to 'intern/cycles/blender/blender_shader.cpp')
-rw-r--r--intern/cycles/blender/blender_shader.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 0cd4b90340b..df21e2640bd 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1158,6 +1158,13 @@ static void add_nodes(Scene *scene,
/* Sync Materials */
+void BlenderSync::sync_materials_simpligy(Shader *shader)
+{
+ ShaderGraph *graph = shader->graph;
+ graph->simplify(scene);
+ shader->tag_update(scene);
+}
+
void BlenderSync::sync_materials(bool update_all)
{
shader_map.set_default(scene->default_surface);
@@ -1203,17 +1210,26 @@ void BlenderSync::sync_materials(bool update_all)
shader->set_graph(graph);
- /* By simplifying the shader graph as soon as possible, some redundant shader nodes
- * might be removed which prevents loading unneccessary attributes later.
+ /* By simplifying the shader graph as soon as possible, some
+ * redundant shader nodes might be removed which prevents loading
+ * unnecessary attributes later.
*
- * However, since graph simplification also accounts for e.g. mix weight, this would
- * cause frequent expensive resyncs in interactive sessions, so for those sessions
- * optimization is only performed right before compiling. */
+ * However, since graph simplification also accounts for e.g. mix
+ * weight, this would cause frequent expensive resyncs in interactive
+ * sessions, so for those sessions optimization is only performed
+ * right before compiling.
+ */
if(!preview) {
- pool.push(function_bind(&ShaderGraph::simplify, shader->graph, scene));
+ pool.push(function_bind(&BlenderSync::sync_materials_simpligy,
+ this,
+ shader));
+ }
+ else {
+ /* NOTE: Update tagging can access links which are being
+ * optimized out.
+ */
+ shader->tag_update(scene);
}
-
- shader->tag_update(scene);
}
}