[Bf-blender-cvs] [f918012] object_nodes: Represent nested node blocks in the graphviz debug dump.
Lukas Tönne
noreply at git.blender.org
Tue Jan 12 12:38:30 CET 2016
Commit: f9180128665ef0ed7ad500e6dd8abd249e29476c
Author: Lukas Tönne
Date: Sat Jan 9 17:40:19 2016 +0100
Branches: object_nodes
https://developer.blender.org/rBf9180128665ef0ed7ad500e6dd8abd249e29476c
Represent nested node blocks in the graphviz debug dump.
===================================================================
M source/blender/blenvm/compile/bvm_nodegraph.cc
M source/blender/blenvm/util/bvm_util_debug.h
===================================================================
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index b2de181..957ecd4 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -35,6 +35,7 @@
#include <cassert>
#include <cstdio>
#include <sstream>
+#include <algorithm>
#include "bvm_nodegraph.h"
#include "bvm_opcode.h"
@@ -889,6 +890,14 @@ void NodeGraph::remove_unused_nodes()
used_nodes_append(output.key.node, used_nodes);
}
/* make sure unused inputs don't leave dangling node pointers */
+ for (NodeGraph::NodeBlockList::iterator it = blocks.begin(); it != blocks.end(); ++it) {
+ NodeBlock &block = *it;
+ NodeSet used_block_nodes;
+ std::set_intersection(used_nodes.begin(), used_nodes.end(),
+ block.nodes.begin(), block.nodes.end(),
+ std::inserter(used_block_nodes, used_block_nodes.end()));
+ block.nodes = used_block_nodes;
+ }
for (NodeGraph::InputList::iterator it = inputs.begin(); it != inputs.end(); ++it) {
Input &input = *it;
if (used_nodes.find(input.key.node) == used_nodes.end()) {
diff --git a/source/blender/blenvm/util/bvm_util_debug.h b/source/blender/blenvm/util/bvm_util_debug.h
index 8655534..1a910f8 100644
--- a/source/blender/blenvm/util/bvm_util_debug.h
+++ b/source/blender/blenvm/util/bvm_util_debug.h
@@ -300,6 +300,45 @@ struct NodeGraphDumper {
}
}
+ static int get_block_depth(const NodeBlock *block)
+ {
+ int depth = -1;
+ while (block) {
+ block = block->parent;
+ ++depth;
+ }
+ return depth;
+ }
+
+ typedef std::set<const NodeBlock *> BlockSet;
+ typedef std::map<const NodeBlock *, BlockSet> BlockChildMap;
+
+ inline void dump_block(const NodeBlock &block, const BlockChildMap &block_children) const
+ {
+ static const char *style = "filled,rounded";
+ int depth = get_block_depth(&block);
+ int gray_level = max_ii(100 - depth * 10, 0);
+
+ debug_fprintf(ctx, "subgraph \"cluster_%p\" {" NL, &block);
+ debug_fprintf(ctx, "margin=\"%d\";" NL, 16);
+ debug_fprintf(ctx, "style=\"%s\";" NL, style);
+ debug_fprintf(ctx, "fillcolor=\"gray%d\"" NL, gray_level);
+
+ for (NodeSet::const_iterator it = block.nodes.begin(); it != block.nodes.end(); ++it) {
+ const NodeInstance *node = *it;
+ dump_node(node);
+ }
+
+ BlockChildMap::const_iterator it = block_children.find(&block);
+ if (it != block_children.end()) {
+ for (BlockSet::const_iterator it_child = it->second.begin(); it_child != it->second.end(); ++it_child) {
+ dump_block(**it_child, block_children);
+ }
+ }
+
+ debug_fprintf(ctx, "}" NL);
+ }
+
inline void dump_graph(const NodeGraph *graph, const string &label) const
{
debug_fprintf(ctx, "digraph depgraph {" NL);
@@ -311,10 +350,16 @@ struct NodeGraphDumper {
debug_fprintf(ctx, ",label=\"%s\"", label.c_str());
// debug_fprintf(ctx, ",splines=ortho");
debug_fprintf(ctx, "];" NL);
-
- for (NodeGraph::NodeInstanceMap::const_iterator it = graph->nodes.begin(); it != graph->nodes.end(); ++it) {
- const NodeInstance *node = it->second;
- dump_node(node);
+
+ BlockChildMap block_children;
+ for (NodeGraph::NodeBlockList::const_iterator it = graph->blocks.begin(); it != graph->blocks.end(); ++it) {
+ const NodeBlock &block = *it;
+ if (block.parent)
+ block_children[block.parent].insert(&block);
+ }
+ if (!graph->blocks.empty()) {
+ /* first block is main */
+ dump_block(graph->blocks.front(), block_children);
}
for (NodeGraph::InputList::const_iterator it = graph->inputs.begin(); it != graph->inputs.end(); ++it) {
More information about the Bf-blender-cvs
mailing list