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
This commit is contained in:
Sergey Sharybin
2015-11-25 13:07:29 +05:00
parent de35827612
commit 443b159f02
6 changed files with 65 additions and 51 deletions

View File

@@ -698,7 +698,7 @@ void OSLCompiler::parameter_array(const char *name, const Transform tfm[], int a
ss->Parameter(name, type, (const float *)tfm);
}
void OSLCompiler::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input)
void OSLCompiler::find_dependencies(ShaderNodeSet& dependencies, ShaderInput *input)
{
ShaderNode *node = (input->link)? input->link->parent: NULL;
@@ -711,9 +711,9 @@ void OSLCompiler::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput
}
}
void OSLCompiler::generate_nodes(const set<ShaderNode*>& nodes)
void OSLCompiler::generate_nodes(const ShaderNodeSet& nodes)
{
set<ShaderNode*> done;
ShaderNodeSet done;
bool nodes_done;
do {
@@ -764,7 +764,7 @@ OSL::ShadingAttribStateRef OSLCompiler::compile_type(Shader *shader, ShaderGraph
OSL::ShadingAttribStateRef group = ss->ShaderGroupBegin(shader->name.c_str());
ShaderNode *output = graph->output();
set<ShaderNode*> dependencies;
ShaderNodeSet dependencies;
if(type == SHADER_TYPE_SURFACE) {
/* generate surface shader */