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-12-15 19:56:27 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-12-28 14:37:48 +0300
commit738f6d8127a18f5bbb748419bc30faec40550532 (patch)
tree55979af0cbd93b72518079b4f55ae8a9e4b80453 /intern/cycles/render/graph.h
parentdaf6f5f81e241484ea8afc5d70ef3027969e5ac1 (diff)
Cycles: Implement node deduplication routines
The idea of this commit is to merge nodes which has identical settings and matching inputs into a single node in order to minimize number of SVM instructions. This is quite simple bottom-top graph traversal and the trickiest part is how to compare node settings without too much trouble which seems to be solved is quite clean way. Still possibilities for further improvements: - Support comparison of BSDF nodes - Support comparison of volume nodes - Support comparison of curve mapping/ramp nodes Reviewers: brecht, juicyfruit, dingto Differential Revision: https://developer.blender.org/D1673
Diffstat (limited to 'intern/cycles/render/graph.h')
-rw-r--r--intern/cycles/render/graph.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 2f852d6b889..0382cbcfa18 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -238,6 +238,21 @@ public:
* nodes group.
*/
virtual int get_feature() { return bump == SHADER_BUMP_NONE ? 0 : NODE_FEATURE_BUMP; }
+
+ /* Check whether settings of the node equals to another one.
+ *
+ * This is mainly used to check whether two nodes can be merged
+ * together. Meaning, runtime stuff like node id and unbound slots
+ * will be ignored for comparison.
+ *
+ * NOTE: If some node can't be de-duplicated for whatever reason it
+ * is to be handled in the subclass.
+ */
+ virtual bool equals(const ShaderNode *other)
+ {
+ return name == other->name &&
+ bump == other->bump;
+ }
};
@@ -311,13 +326,16 @@ protected:
void copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap);
void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack);
- void clean(Scene *scene);
- void simplify_settings(Scene *scene);
- void constant_fold();
void bump_from_displacement();
void refine_bump_nodes();
void default_inputs(bool do_osl);
void transform_multi_closure(ShaderNode *node, ShaderOutput *weight_out, bool volume);
+
+ /* Graph simplification routines. */
+ void clean(Scene *scene);
+ void constant_fold();
+ void simplify_settings(Scene *scene);
+ void deduplicate_nodes();
};
CCL_NAMESPACE_END