[Bf-blender-cvs] [d5d35d5] object_nodes: Moved debugging code output node graph into a utility file.

Lukas Tönne noreply at git.blender.org
Thu Dec 10 12:52:10 CET 2015


Commit: d5d35d5b150ccd467f83d783f1a18d90fde8ba88
Author: Lukas Tönne
Date:   Thu Dec 10 12:51:47 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBd5d35d5b150ccd467f83d783f1a18d90fde8ba88

Moved debugging code output node graph into a utility file.

===================================================================

M	source/blender/blenvm/CMakeLists.txt
M	source/blender/blenvm/compile/bvm_nodegraph.cc
M	source/blender/blenvm/compile/bvm_nodegraph.h
M	source/blender/blenvm/intern/bvm_api.cc
A	source/blender/blenvm/util/bvm_util_debug.h

===================================================================

diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
index 0967b78..ccdf26e 100644
--- a/source/blender/blenvm/CMakeLists.txt
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -45,6 +45,7 @@ set(INC_SYS
 set(SRC
 	intern/bvm_api.cc
 
+	util/bvm_util_debug.h
 	util/bvm_util_hash.h
 	util/bvm_util_map.h
 	util/bvm_util_math.h
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index 6be78dc..1a62c3e 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -761,347 +761,6 @@ void NodeGraph::finalize()
 	remove_unused_nodes();
 }
 
-/* === DEBUGGING === */
-
-#define NL "\r\n"
-
-void NodeGraph::dump(std::ostream &s)
-{
-	s << "NodeGraph\n";
-	
-	for (NodeInstanceMap::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
-		const NodeInstance *node = it->second;
-		const NodeType *type = node->type;
-		s << "  Node '" << node->name << "'\n";
-		
-		for (int i = 0; i < type->num_inputs(); ++i) {
-			const NodeInput *socket = type->find_input(i);
-			
-			s << "    Input '" << socket->name << "'";
-			NodeInstance *link_node = node->find_input_link_node(i);
-			const NodeOutput *link_socket = node->find_input_link_socket(i);
-//			Value *value = node->find_input_value(i);
-			
-			BLI_assert((bool)link_node == (bool)link_socket);
-			
-			if (link_node && link_socket) {
-				s << " <== " << link_node->name << ":" << link_socket->name;
-				// TODO value print function
-//				s << " (" << value << ")\n";
-				s << "\n";
-			}
-			else {
-				// TODO value print function
-//				s << " " << value << "\n";
-				s << "\n";
-			}
-		}
-		
-		for (int i = 0; i < type->num_outputs(); ++i) {
-			const NodeOutput *socket = type->find_output(i);
-			
-			s << "    Output '" << socket->name << "'";
-//			Value *value = node->find_output_value(i);
-			
-			// TODO value print function
-//			s << " " << value << "\n";
-			s << "\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;
-};
-
-static void debug_fprintf(const DebugContext &ctx, const char *fmt, ...) ATTR_PRINTF_FORMAT(2, 3);
-static void debug_fprintf(const DebugContext &ctx, const char *fmt, ...)
-{
-	va_list args;
-	va_start(args, fmt);
-	vfprintf(ctx.file, fmt, args);
-	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;
-}
-
-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;
-	}
-	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());
-		}
-		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\"", 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;
-	const SocketPair &key = input ? input->key : output->key;
-	{
-		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;
-		float penwidth = 1.0f;
-		
-		debug_fprintf(ctx, "// %s\n", name.c_str());
-		debug_fprintf(ctx, "\"%s_%p\"", id.c_str(), ptr);
-		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, ",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);
-	}
-
-	if (key.node) {
-		const float penwidth = 2.0f;
-		if (input) {
-			const NodeGraph::Input *tail = input;
-			const NodeInstance *head = key.node;
-			const string &head_socket = key.socket;
-			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);
-			
-			debug_fprintf(ctx, "[");
-			/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
-			debug_fprintf(ctx, "id=\"A%sB%s\"",
-			              head->name.c_str(),
-			              tail->name.c_str());
-			
-			debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
-			debug_fprintf(ctx, "];" NL);
-			debug_fprintf(ctx, NL);
-		}
-		else {
-			const NodeInstance *tail = key.node;
-			const string &tail_socket = key.socket;
-			int tail_index = debug_output_index(tail, tail_socket);
-			const NodeGraph::Output *head = output;
-			debug_fprintf(ctx, "// %s:%s -> %s\n",
-			              tail->name.c_str(), tail_socket.c_str(),
-			              head->name.c_str());
-			debug_fprintf(ctx, "\"node_%p\":\"O%s_%d\"", tail, tail_socket.c_str(), tail_index);
-			debug_fprintf(ctx, " -> ");
-			debug_fprintf(ctx, "\"output_%p\"", head);
-			
-			debug_fprintf(ctx, "[");
-			/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
-			debug_fprintf(ctx, "id=\"A%sB%s:O%s_%d\"",
-			              head->name.c_str(),
-			              tail->name.c_str(), tail_socket.c_str(), tail_index);
-			
-			debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
-			debug_fprintf(ctx, "];" NL);
-			debug_fprintf(ctx, NL);
-		}
-	}
-}
-
-static void debug_graphviz_node_links(const DebugContext &ctx, const NodeGraph *graph, const NodeInstance *node)
-{
-	float penwidth = 2.0f;
-	const char *localarg_color = "gray50";
-	
-	for (NodeInstance::InputMap::const_iterator it = node->inputs.begin(); it != node->inputs.end(); ++it) {
-		const NodeInstance::InputInstance &input = it->second;
-		
-		if (input.link_node && input.link_socket) {
-			const NodeInstance *tail = input.link_node;
-			const string &tail_socket = input.link_socket->name;
-			int tail_index = debug_output_index(tail, tail_socket);
-			const NodeInstance *head = node;
-			const string &head_socket = it->first;
-			int head_index = debug_input_index(head, head_socket);
-			debug_fprintf(ctx, "// %s:%s -> %s:%s\n",
-			              tail->name.c_str(), tail_socket.c_str(),
-			              head->name.c_str(), head_socket.c_str());
-			debug_fprintf(ctx, "\"node_%p\":\"O%s_%d\"", tail, tail_socket.c_str(), tail_index);
-			debug_fprintf(ctx, " -> ");
-			debug_fprintf(ctx, "\"node_%p\":\"I%s_%d\"", head, head_socket.c_str(), head_index);
-	
-			debug_fprintf(ctx, "[");
-			/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
-			debug_fprintf(ctx, "id=\"A%s:O%s_%dB%s:O%s_%d\"",
-			              head->name.c_str(), head_socket.c_str(), head_index,
-			              tail->name.c_str(), tail_socket.c_str(), tail_index);
-			
-			debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
-			debug_fprintf(ctx, "];" NL);
-			debug_fprintf(ctx, NL);
-		}
-	}
-
-	/* local argument outputs */
-	for (int i = 0; i < node->num_outputs(); ++i) {
-		ConstSocketPair key = node->output(i);
-		const NodeOut

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list