[Bf-blender-cvs] [65b4da0] object_nodes: Cleanup: class for debug dumping functions for node graphs.
Lukas Tönne
noreply at git.blender.org
Tue Jan 12 12:38:29 CET 2016
Commit: 65b4da0cc3c222705de18e549b141e6ed38a715f
Author: Lukas Tönne
Date: Sat Jan 9 15:01:30 2016 +0100
Branches: object_nodes
https://developer.blender.org/rB65b4da0cc3c222705de18e549b141e6ed38a715f
Cleanup: class for debug dumping functions for node graphs.
===================================================================
M source/blender/blenvm/intern/bvm_api.cc
M source/blender/blenvm/util/bvm_util_debug.h
===================================================================
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 11c8042..ff37731 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -472,13 +472,16 @@ void BVM_debug_forcefield_nodes(bNodeTree *btree, FILE *debug_file, const char *
switch (mode) {
case BVM_DEBUG_NODES:
- case BVM_DEBUG_NODES_UNOPTIMIZED:
- debug::dump_graphviz(debug_file, &graph, "Force Field Graph");
+ case BVM_DEBUG_NODES_UNOPTIMIZED: {
+ debug::NodeGraphDumper dumper(debug_file);
+ dumper.dump_graph(&graph, "Force Field Graph");
break;
- case BVM_DEBUG_CODEGEN:
+ }
+ case BVM_DEBUG_CODEGEN: {
DebugGraphvizCompiler compiler;
compiler.compile_function(graph, debug_file, label);
break;
+ }
}
}
@@ -1009,13 +1012,16 @@ void BVM_debug_texture_nodes(bNodeTree *btree, FILE *debug_file, const char *lab
switch (mode) {
case BVM_DEBUG_NODES:
- case BVM_DEBUG_NODES_UNOPTIMIZED:
- debug::dump_graphviz(debug_file, &graph, "Texture Node Graph");
+ case BVM_DEBUG_NODES_UNOPTIMIZED: {
+ debug::NodeGraphDumper dumper(debug_file);
+ dumper.dump_graph(&graph, "Texture Node Graph");
break;
- case BVM_DEBUG_CODEGEN:
+ }
+ case BVM_DEBUG_CODEGEN: {
DebugGraphvizCompiler compiler;
compiler.compile_function(graph, debug_file, label);
break;
+ }
}
}
@@ -1092,13 +1098,16 @@ void BVM_debug_modifier_nodes(struct bNodeTree *btree, FILE *debug_file, const c
switch (mode) {
case BVM_DEBUG_NODES:
- case BVM_DEBUG_NODES_UNOPTIMIZED:
- debug::dump_graphviz(debug_file, &graph, "Modifier Node Graph");
+ case BVM_DEBUG_NODES_UNOPTIMIZED: {
+ debug::NodeGraphDumper dumper(debug_file);
+ dumper.dump_graph(&graph, "Modifier Node Graph");
break;
- case BVM_DEBUG_CODEGEN:
+ }
+ case BVM_DEBUG_CODEGEN: {
DebugGraphvizCompiler compiler;
compiler.compile_function(graph, debug_file, label);
break;
+ }
}
}
@@ -1164,13 +1173,16 @@ void BVM_debug_dupli_nodes(struct bNodeTree *btree, FILE *debug_file, const char
switch (mode) {
case BVM_DEBUG_NODES:
- case BVM_DEBUG_NODES_UNOPTIMIZED:
- debug::dump_graphviz(debug_file, &graph, "Dupli Node Graph");
+ case BVM_DEBUG_NODES_UNOPTIMIZED: {
+ debug::NodeGraphDumper dumper(debug_file);
+ dumper.dump_graph(&graph, "Dupli Node Graph");
break;
- case BVM_DEBUG_CODEGEN:
+ }
+ case BVM_DEBUG_CODEGEN: {
DebugGraphvizCompiler compiler;
compiler.compile_function(graph, debug_file, label);
break;
+ }
}
}
diff --git a/source/blender/blenvm/util/bvm_util_debug.h b/source/blender/blenvm/util/bvm_util_debug.h
index faef779..8655534 100644
--- a/source/blender/blenvm/util/bvm_util_debug.h
+++ b/source/blender/blenvm/util/bvm_util_debug.h
@@ -41,15 +41,6 @@ namespace debug {
#define NL "\r\n"
-static const char *debug_graphviz_fontname = "helvetica";
-static float debug_graphviz_graph_label_size = 20.0f;
-static float debug_graphviz_node_label_size = 14.0f;
-static const char *debug_graphviz_node_color_function = "gainsboro";
-static const char *debug_graphviz_node_color_kernel = "lightsalmon1";
-static const char *debug_graphviz_node_color_pass = "gray96";
-static const char *debug_graphviz_node_color_argument = "steelblue";
-static const char *debug_graphviz_node_color_return_value = "orange";
-
struct DebugContext {
FILE *file;
};
@@ -63,105 +54,86 @@ static void debug_fprintf(const DebugContext &ctx, const char *fmt, ...)
va_end(args);
}
-inline static int debug_input_index(const NodeInstance *node, const string &name)
-{
- for (int i = 0; i < node->type->num_inputs(); ++i) {
- if (node->type->find_input(i)->name == name)
- return i;
- }
- return -1;
-}
+static const char *fontname = "helvetica";
+static float graph_label_size = 20.0f;
+static float node_label_size = 14.0f;
+static const char *node_color_function = "gainsboro";
+static const char *node_color_kernel = "lightsalmon1";
+static const char *node_color_pass = "gray96";
+static const char *node_color_argument = "steelblue";
+static const char *node_color_return_value = "orange";
-inline static int debug_output_index(const NodeInstance *node, const string &name)
-{
- for (int i = 0; i < node->type->num_outputs(); ++i) {
- if (node->type->find_output(i)->name == name)
- return i;
+struct NodeGraphDumper {
+ NodeGraphDumper(FILE *f) :
+ file(f)
+ {
+ ctx.file = f;
}
- return -1;
-}
-
-static void debug_graphviz_node(const DebugContext &ctx, const NodeInstance *node)
-{
- const char *shape = "box";
- const char *style = "filled,rounded";
- const char *color = "black";
- const char *fillcolor =
- (node->type->is_pass_node()) ? debug_graphviz_node_color_pass :
- (node->type->is_kernel_node()) ? debug_graphviz_node_color_kernel :
- debug_graphviz_node_color_function;
- float penwidth = 1.0f;
- string name = node->type->name();
- debug_fprintf(ctx, "// %s\n", node->name.c_str());
- debug_fprintf(ctx, "\"node_%p\"", node);
- debug_fprintf(ctx, "[");
-
- /* html label including rows for input/output sockets
- * http://www.graphviz.org/doc/info/shapes.html#html
- */
- debug_fprintf(ctx, "label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"4\">");
- debug_fprintf(ctx, "<TR><TD COLSPAN=\"2\">%s</TD></TR>", name.c_str());
- int numin = node->type->num_inputs();
- int numout = node->type->num_outputs();
- for (int i = 0; i < numin || i < numout; ++i) {
- debug_fprintf(ctx, "<TR>");
-
- if (i < numin) {
- string name_in = node->type->find_input(i)->name;
- debug_fprintf(ctx, "<TD PORT=\"I%s_%d\" BORDER=\"1\">%s</TD>", name_in.c_str(), i, name_in.c_str());
+ inline static int input_index(const NodeInstance *node, const string &name)
+ {
+ for (int i = 0; i < node->type->num_inputs(); ++i) {
+ if (node->type->find_input(i)->name == name)
+ return i;
}
- else
- debug_fprintf(ctx, "<TD></TD>");
-
- if (i < numout) {
- string name_out = node->type->find_output(i)->name;
- debug_fprintf(ctx, "<TD PORT=\"O%s_%d\" BORDER=\"1\">%s</TD>", name_out.c_str(), i, name_out.c_str());
+ return -1;
+ }
+
+ inline static int output_index(const NodeInstance *node, const string &name)
+ {
+ for (int i = 0; i < node->type->num_outputs(); ++i) {
+ if (node->type->find_output(i)->name == name)
+ return i;
}
- else
- debug_fprintf(ctx, "<TD></TD>");
-
- debug_fprintf(ctx, "</TR>");
+ return -1;
}
- debug_fprintf(ctx, "</TABLE>>");
- debug_fprintf(ctx, ",fontname=\"%s\"", debug_graphviz_fontname);
- debug_fprintf(ctx, ",fontsize=\"%f\"", debug_graphviz_node_label_size);
- debug_fprintf(ctx, ",shape=\"%s\"", shape);
- debug_fprintf(ctx, ",style=\"%s\"", style);
- debug_fprintf(ctx, ",color=\"%s\"", color);
- debug_fprintf(ctx, ",fillcolor=\"%s\"", fillcolor);
- debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
- debug_fprintf(ctx, "];" NL);
- debug_fprintf(ctx, NL);
-}
-
-static void debug_graphviz_input_output(const DebugContext &ctx,
- const NodeGraph::Input *input,
- const NodeGraph::Output *output)
-{
- string name = input ? input->name : output->name;
- string id = input ? "input" : "output";
- void *ptr = input ? (void *)input : (void *)output;
+ inline void dump_node(const NodeInstance *node) const
{
const char *shape = "box";
const char *style = "filled,rounded";
const char *color = "black";
- const char *fillcolor = input ?
- debug_graphviz_node_color_argument :
- debug_graphviz_node_color_return_value;
+ const char *fillcolor =
+ (node->type->is_pass_node()) ? node_color_pass :
+ (node->type->is_kernel_node()) ? node_color_kernel :
+ node_color_function;
float penwidth = 1.0f;
+ string name = node->type->name();
- debug_fprintf(ctx, "// %s\n", name.c_str());
- debug_fprintf(ctx, "\"%s_%p\"", id.c_str(), ptr);
+ debug_fprintf(ctx, "// %s\n", node->name.c_str());
+ debug_fprintf(ctx, "\"node_%p\"", node);
debug_fprintf(ctx, "[");
/* html label including rows for input/output sockets
* http://www.graphviz.org/doc/info/shapes.html#html
*/
- debug_fprintf(ctx, "label=\"%s\"", name.c_str());
- debug_fprintf(ctx, ",fontname=\"%s\"", debug_graphviz_fontname);
- debug_fprintf(ctx, ",fontsize=\"%f\"", debug_graphviz_node_label_size);
+ debug_fprintf(ctx, "label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"4\">");
+ debug_fprintf(ctx, "<TR><TD COLSPAN=\"2\">%s</TD></TR>", name.c_str());
+ int numin = node->type->num_inputs();
+ int numout = node->type->num_outputs();
+ for (int i = 0; i < numin || i < numout; ++i) {
+ debug_fprintf(ctx, "<TR>");
+
+ if (i < numin) {
+ string name_in = node->type->find_input(i)->name;
+ debug_fprintf(ctx, "<TD PORT=\"I%s_%d\" BORDER=\"1\">%s</TD>", name_in.c_str(), i, name_in.c_str());
+ }
+ else
+ debug_fprintf(ctx, "<TD></TD>");
+
+ if (i < numout) {
+ string name_out = node->type->find_output(i)->name;
+ debug_fprintf(ctx, "<TD PORT=\"O%s_%d\" BORDER=\"1\">%s</TD>", name_out.c_str(), i, name_out.c_str());
+ }
+ else
+ debug_fprintf(ctx, "<TD></TD>");
+
+ debug_fprintf(ctx, "</TR>");
+ }
+ debug_fprintf(ctx, "</TABLE>>");
+
+ debug_fprintf(ctx, ",fontname=\"%s\"", fontname);
+ debug_fprintf(ctx, ",fontsize=\"%f\"", node_label_size);
debug_fprintf(ctx, ",shape=\"%s\"", shape);
debug_fprintf(ctx, ",style=\"%s\"", style);
debug_fprintf(ctx, ",color=\"%s\"", color);
@@ -171,109 +143,77 @@ static void debug_graphviz_input_output(const DebugContext &ctx,
debug_fprintf(ctx, NL);
}
- const float penwidth = 2.0f;
- if (input) {
- const OutputKey &key = input->key;
- if (key) {
- const NodeGraph::Input *tail = input;
- const NodeInstance *head = key.node;
- const string &head_socket = key.socket->name;
- debug_fprintf(ctx, "// %s:%s -> %s\n",
- tail->name.c_str(),
- head->name.c_str(), head_socket.c_str());
- debug_fprintf(ctx, "\"input_%p\"", tail);
- debug_fprintf(ctx, " -> ");
- debug_fprintf(ctx, "\"node_%p\"", head);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list