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:
authorLukas Stockner <lukas.stockner@freenet.de>2016-12-15 01:47:39 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2017-03-27 06:36:49 +0300
commit5aaa643947929cf807c349b2b5fe33d4dc669c3d (patch)
tree091bf2c52f7a935525004bab2ceabeba989fafe6 /intern/cycles/blender
parent086320a62e108b6e640f2b2453b8f1f0a946e57b (diff)
Cycles: Optimize shaders earlier to skip unneccessary attributes for noninteractive rendering
Before, Cycles would first sync the shader exactly as shown in the UI, then determine and sync the used attributes and later optimize the shader. Therefore, even completely unconnected nodes would cause unneccessary attributes to be synced. The reason for this is to avoid frequent resyncs when editing shaders interactively, but it can still be avoided for noninteractive renders - which is what this commit does. Reviewed by: sergey Differential Revision: https://developer.blender.org/D2285
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_shader.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 8baa53fc2ec..f35565d8330 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -28,6 +28,7 @@
#include "util_debug.h"
#include "util_string.h"
+#include "util_task.h"
CCL_NAMESPACE_BEGIN
@@ -1164,6 +1165,8 @@ void BlenderSync::sync_materials(bool update_all)
/* material loop */
BL::BlendData::materials_iterator b_mat;
+ TaskPool pool;
+
for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
Shader *shader;
@@ -1199,9 +1202,22 @@ void BlenderSync::sync_materials(bool update_all)
shader->displacement_method = (experimental) ? get_displacement_method(cmat) : DISPLACE_BUMP;
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.
+ *
+ * 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));
+ }
+
shader->tag_update(scene);
}
}
+
+ pool.wait_work();
}
/* Sync World */