diff options
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r-- | intern/cycles/render/graph.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index d90e5c4b2c9..45b08832fea 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -835,5 +835,47 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight } } +void ShaderGraph::dump_graph(const char *filename) +{ + FILE *fd = fopen(filename, "w"); + + if(fd == NULL) { + printf("Error opening file for dumping the graph: %s\n", filename); + return; + } + + fprintf(fd, "digraph dependencygraph {\n"); + fprintf(fd, "ranksep=1.5\n"); + fprintf(fd, "splines=false\n"); + + foreach(ShaderNode *node, nodes) { + fprintf(fd, "// NODE: %p\n", node); + fprintf(fd, + "\"%p\" [shape=record,label=\"%s\"]\n", + node, + node->name.c_str()); + } + + foreach(ShaderNode *node, nodes) { + foreach(ShaderOutput *output, node->outputs) { + foreach(ShaderInput *input, output->links) { + fprintf(fd, + "// CONNECTION: %p->%p (%s:%s)\n", + output, + input, + output->name, input->name); + fprintf(fd, + "\"%p\":s -> \"%p\":n [label=\"%s:%s\"]\n", + output->parent, + input->parent, + output->name, input->name); + } + } + } + + fprintf(fd, "}\n"); + fclose(fd); +} + CCL_NAMESPACE_END |