diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 11:07:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 11:07:32 +0300 |
commit | 443b159f023a872472d8e61c7270dab472a3d8ee (patch) | |
tree | 011015dbde30f6adc8b95c2710e2e5a5f13ca528 /intern/cycles/render/graph.h | |
parent | de35827612f85511aed50b9f05953ad857fe7e1c (diff) |
Cycles: Ensure order of shader nodes in the dependnecies set
The issue was than nodes dependencies were stored as set<ShaderNode*> which
is actually a so called "strict weak ordered", meaning order of nodes in
the set is strictly defined, but based on the ShaderNode pointer. This means
that between different render invokations order of original nodes could be
different due to different pointers allocated for ShaderNode.
This commit makes it so dependencies and maps used for ShaderNodes are based
on the node->id which has much more predictable order. It's still possible
to trick the system by doing some crazy edits during viewport rendfer and
cause difference between viewport and final render stacks.
Reviewers: brecht
Reviewed By: brecht
Subscribers: LazyDodo
Differential Revision: https://developer.blender.org/D1630
Diffstat (limited to 'intern/cycles/render/graph.h')
-rw-r--r-- | intern/cycles/render/graph.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index a2c210f4f60..6ad40720d4c 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -254,6 +254,18 @@ public: virtual void compile(SVMCompiler& compiler); \ virtual void compile(OSLCompiler& compiler); \ +class ShaderNodeIDComparator +{ +public: + bool operator()(const ShaderNode *n1, const ShaderNode *n2) const + { + return n1->id < n2->id; + } +}; + +typedef set<ShaderNode*, ShaderNodeIDComparator> ShaderNodeSet; +typedef map<ShaderNode*, ShaderNode*, ShaderNodeIDComparator> ShaderNodeMap; + /* Graph * * Shader graph of nodes. Also does graph manipulations for default inputs, @@ -290,8 +302,8 @@ public: protected: typedef pair<ShaderNode* const, ShaderNode*> NodePair; - void find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input); - void copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNode*>& nnodemap); + void find_dependencies(ShaderNodeSet& dependencies, ShaderInput *input); + void copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap); void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack); void clean(Scene *scene); |