[Bf-blender-cvs] [e339326] object_nodes: Use dedicated functions for producing graphviz debug output.

Lukas Tönne noreply at git.blender.org
Wed Dec 23 18:11:52 CET 2015


Commit: e33932662108990ab747275dbf75d8b0de5b8548
Author: Lukas Tönne
Date:   Wed Dec 23 18:10:22 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBe33932662108990ab747275dbf75d8b0de5b8548

Use dedicated functions for producing graphviz debug output.

This allows creating unoptimized node graph output dumps without
causing crashes, because the codegen step is not performed when
just producing debug output.

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

M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenvm/BVM_api.h
M	source/blender/blenvm/intern/bvm_api.cc
M	source/blender/makesrna/intern/rna_object_api.c
M	source/blender/makesrna/intern/rna_texture_api.c
M	source/blender/render/intern/source/render_texture.c

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

diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index bf13454..25aee76 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1710,7 +1710,7 @@ static DerivedMesh *mesh_calc_modifier_nodes(Scene *UNUSED(scene), Object *ob, b
 	
 	struct BVMFunction *fn = BVM_function_cache_acquire(ntree);
 	if (!fn) {
-		fn = BVM_gen_modifier_function(ntree, NULL);
+		fn = BVM_gen_modifier_function(ntree);
 		BVM_function_cache_set(ntree, fn);
 	}
 	
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 4ca4054..b807116 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -215,7 +215,7 @@ static void add_object_nodes_to_effectors(EffectorContext *effctx, Scene *scene,
 					BVM_globals_add_nodetree_relations(effctx->eval_globals, ff_ntree);
 					
 					EffectorCache *eff = new_effector_cache(effctx, scene, ob, NULL, ob->pd);
-					eff->function = BVM_gen_forcefield_function(ff_ntree, NULL);
+					eff->function = BVM_gen_forcefield_function(ff_ntree);
 				}
 				
 				break;
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index bf9f440..2c83d6a 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1153,7 +1153,7 @@ static void make_duplis_nodetree(struct bNodeTree *ntree, const DupliContext *du
 {
 	struct BVMFunction *fn = BVM_function_cache_acquire(ntree);
 	if (!fn) {
-		fn = BVM_gen_dupli_function(ntree, NULL);
+		fn = BVM_gen_dupli_function(ntree);
 		BVM_function_cache_set(ntree, fn);
 	}
 	
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index 012a5e0..ccc25f6 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -120,7 +120,8 @@ void BVM_context_free(struct BVMEvalContext *context);
 struct Object;
 struct EffectedPoint;
 
-struct BVMFunction *BVM_gen_forcefield_function(struct bNodeTree *btree, FILE *debug_file);
+struct BVMFunction *BVM_gen_forcefield_function(struct bNodeTree *btree);
+void BVM_debug_forcefield_nodes(struct bNodeTree *btree, FILE *debug_file, bool finalize);
 
 void BVM_eval_forcefield(struct BVMEvalGlobals *globals, struct BVMEvalContext *context, struct BVMFunction *fn,
                          struct Object *effob, const struct EffectedPoint *point, float force[3], float impulse[3]);
@@ -130,7 +131,8 @@ void BVM_eval_forcefield(struct BVMEvalGlobals *globals, struct BVMEvalContext *
 struct Tex;
 struct TexResult;
 
-struct BVMFunction *BVM_gen_texture_function(struct Tex *tex, struct bNodeTree *btree, FILE *debug_file);
+struct BVMFunction *BVM_gen_texture_function(struct bNodeTree *btree);
+void BVM_debug_texture_nodes(struct bNodeTree *btree, FILE *debug_file, bool finalize);
 
 void BVM_eval_texture(struct BVMEvalContext *context, struct BVMFunction *fn,
                       struct TexResult *target,
@@ -142,7 +144,8 @@ void BVM_eval_texture(struct BVMEvalContext *context, struct BVMFunction *fn,
 struct DerivedMesh;
 struct Mesh;
 
-struct BVMFunction *BVM_gen_modifier_function(struct bNodeTree *btree, FILE *debug_file);
+struct BVMFunction *BVM_gen_modifier_function(struct bNodeTree *btree);
+void BVM_debug_modifier_nodes(struct bNodeTree *btree, FILE *debug_file, bool finalize);
 
 struct DerivedMesh *BVM_eval_modifier(struct BVMEvalGlobals *globals,
                                       struct BVMEvalContext *context,
@@ -154,7 +157,8 @@ struct DerivedMesh *BVM_eval_modifier(struct BVMEvalGlobals *globals,
 
 struct DupliContainer;
 
-struct BVMFunction *BVM_gen_dupli_function(struct bNodeTree *btree, FILE *debug_file);
+struct BVMFunction *BVM_gen_dupli_function(struct bNodeTree *btree);
+void BVM_debug_dupli_nodes(struct bNodeTree *btree, FILE *debug_file, bool finalize);
 
 void BVM_eval_dupli(struct BVMEvalGlobals *globals,
                     struct BVMEvalContext *context,
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 30d0b56..51f1314 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -430,28 +430,28 @@ static void parse_py_nodes(bNodeTree *btree, bvm::NodeGraph *graph)
 	RNA_parameter_list_free(&list);
 }
 
-struct BVMFunction *BVM_gen_forcefield_function(bNodeTree *btree, FILE *debug_file)
+static void init_forcefield_graph(bvm::NodeGraph &graph)
 {
 	using namespace bvm;
 	
-	NodeGraph graph;
-	{
-		graph.add_input("effector.object", TYPE_POINTER);
-		graph.add_input("effector.position", TYPE_FLOAT3);
-		graph.add_input("effector.velocity", TYPE_FLOAT3);
-		
-		float zero[3] = {0.0f, 0.0f, 0.0f};
-		graph.add_output("force", TYPE_FLOAT3, zero);
-		graph.add_output("impulse", TYPE_FLOAT3, zero);
-	}
+	graph.add_input("effector.object", TYPE_POINTER);
+	graph.add_input("effector.position", TYPE_FLOAT3);
+	graph.add_input("effector.velocity", TYPE_FLOAT3);
+	
+	float zero[3] = {0.0f, 0.0f, 0.0f};
+	graph.add_output("force", TYPE_FLOAT3, zero);
+	graph.add_output("impulse", TYPE_FLOAT3, zero);
+}
+
+struct BVMFunction *BVM_gen_forcefield_function(bNodeTree *btree)
+{
+	using namespace bvm;
 	
+	NodeGraph graph;
+	init_forcefield_graph(graph);
 	parse_py_nodes(btree, &graph);
 	graph.finalize();
 	
-	if (debug_file) {
-		debug::dump_graphviz(debug_file, &graph, "Force Field Graph");
-	}
-	
 	BVMCompiler compiler;
 	Function *fn = compiler.compile_function(graph);
 	Function::retain(fn);
@@ -459,6 +459,19 @@ struct BVMFunction *BVM_gen_forcefield_function(bNodeTree *btree, FILE *debug_fi
 	return (BVMFunction *)fn;
 }
 
+void BVM_debug_forcefield_nodes(bNodeTree *btree, FILE *debug_file, bool finalize)
+{
+	using namespace bvm;
+	
+	NodeGraph graph;
+	init_forcefield_graph(graph);
+	parse_py_nodes(btree, &graph);
+	if (finalize)
+		graph.finalize();
+	
+	debug::dump_graphviz(debug_file, &graph, "Force Field Graph");
+}
+
 void BVM_eval_forcefield(struct BVMEvalGlobals *globals, struct BVMEvalContext *ctx, struct BVMFunction *fn,
                          struct Object *effob, const EffectedPoint *point, float force[3], float impulse[3])
 {
@@ -944,31 +957,31 @@ static void parse_tex_nodes(bNodeTree *btree, bvm::NodeGraph *graph)
 	}
 }
 
+static void init_texture_graph(bvm::NodeGraph &graph)
+{
+	using namespace bvm;
+	
+	graph.add_input("texture.co", TYPE_FLOAT3);
+	graph.add_input("texture.dxt", TYPE_FLOAT3);
+	graph.add_input("texture.dyt", TYPE_FLOAT3);
+	graph.add_input("texture.cfra", TYPE_INT);
+	graph.add_input("texture.osatex", TYPE_INT);
+	
+	float C[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+	float N[3] = {0.0f, 0.0f, 0.0f};
+	graph.add_output("color", TYPE_FLOAT4, C);
+	graph.add_output("normal", TYPE_FLOAT3, N);
+}
 
-struct BVMFunction *BVM_gen_texture_function(struct Tex */*tex*/, bNodeTree *btree, FILE *debug_file)
+struct BVMFunction *BVM_gen_texture_function(bNodeTree *btree)
 {
 	using namespace bvm;
 	
 	NodeGraph graph;
-	{
-		graph.add_input("texture.co", TYPE_FLOAT3);
-		graph.add_input("texture.dxt", TYPE_FLOAT3);
-		graph.add_input("texture.dyt", TYPE_FLOAT3);
-		graph.add_input("texture.cfra", TYPE_INT);
-		graph.add_input("texture.osatex", TYPE_INT);
-		
-		float C[4] = {0.0f, 0.0f, 0.0f, 1.0f};
-		float N[3] = {0.0f, 0.0f, 0.0f};
-		graph.add_output("color", TYPE_FLOAT4, C);
-		graph.add_output("normal", TYPE_FLOAT3, N);
-	}
+	init_texture_graph(graph);
 	parse_tex_nodes(btree, &graph);
 	graph.finalize();
 	
-	if (debug_file) {
-		debug::dump_graphviz(debug_file, &graph, "Texture Expression Graph");
-	}
-	
 	BVMCompiler compiler;
 	Function *fn = compiler.compile_function(graph);
 	Function::retain(fn);
@@ -976,6 +989,19 @@ struct BVMFunction *BVM_gen_texture_function(struct Tex */*tex*/, bNodeTree *btr
 	return (BVMFunction *)fn;
 }
 
+void BVM_debug_texture_nodes(bNodeTree *btree, FILE *debug_file, bool finalize)
+{
+	using namespace bvm;
+	
+	NodeGraph graph;
+	init_texture_graph(graph);
+	parse_tex_nodes(btree, &graph);
+	if (finalize)
+		graph.finalize();
+	
+	debug::dump_graphviz(debug_file, &graph, "Texture Expression Graph");
+}
+
 void BVM_eval_texture(struct BVMEvalContext *ctx, struct BVMFunction *fn,
                       struct TexResult *target,
                       float coord[3], float dxt[3], float dyt[3], int osatex,
@@ -1009,25 +1035,27 @@ void BVM_eval_texture(struct BVMEvalContext *ctx, struct BVMFunction *fn,
 
 /* ------------------------------------------------------------------------- */
 
-struct BVMFunction *BVM_gen_modifier_function(struct bNodeTree *btree, FILE *debug_file)
+static void init_modifier_graph(bvm::NodeGraph &graph)
 {
 	using namespace bvm;
 	
-	NodeGraph graph;
 	graph.add_input("iteration", TYPE_INT);
 	graph.add_input("element.index", TYPE_INT);
 	graph.add_input("element.location", TYPE_FLOAT3);
 	graph.add_input("modifier.object", TYPE_POINTER);
 	graph.add_input("modifier.base_mesh", TYPE_POINTER);
 	graph.add_output("mesh", TYPE_MESH, __empty_mesh__);
+}
+
+struct BVMFunction *BVM_gen_modifier_function(struct bNodeTree *btree)
+{
+	using namespace bvm;
 	
+	NodeGraph graph;
+	init_modifier_graph(graph);
 	parse_py_nodes(btree, &graph);
 	graph.finalize();
 	
-	if (debug_file) {
-		debug::dump_graphviz(debug_file, &graph, "Modifier Schedule Graph");
-	}
-	
 	BVMCompiler compiler;
 	Function *fn = compiler.compile_function(graph);
 	Function::retain(fn);
@@ -1035,6 +1063,19 @@ struct BVMFunction *BVM_gen_modifier_function(struct bNodeTree *btree, FILE *deb
 	return (BVMFunction *)fn;
 }
 
+void BVM_debug_modifier_nodes(struct bNodeTree *btree, FILE *debug_file, bool finalize)
+{
+	using namespace bvm;
+	
+	NodeGraph graph;
+	init_modifier_graph(graph);
+	parse_py_nodes(btree, &graph);
+	if (finalize)
+		graph.finalize();
+	
+	debug::dump_graphviz(debug_file, &graph, "Modifier Schedule Graph");
+}
+
 struct DerivedMesh *BVM_eval_modifier(struct BVMEvalGlobals *globals,
                                       struct BVMEvalContext *ctx,
                                       struct BVMFunction *fn,
@@ -1060,21 +1101,23 @@ struct Derive

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list