[Bf-blender-cvs] [04a4f1aa4d6] functions: extract ensure tuple calls function
Jacques Lucke
noreply at git.blender.org
Sat Apr 27 13:25:40 CEST 2019
Commit: 04a4f1aa4d614730846755c70eba8da397d72b3d
Author: Jacques Lucke
Date: Sat Apr 27 10:24:43 2019 +0200
Branches: functions
https://developer.blender.org/rB04a4f1aa4d614730846755c70eba8da397d72b3d
extract ensure tuple calls function
===================================================================
M source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
M source/blender/functions/core/function_graph.hpp
===================================================================
diff --git a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
index 8f26961f5d8..379d009c634 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -3,6 +3,26 @@
namespace FN {
+static void try_ensure_tuple_call_bodies(SharedDataFlowGraph &graph)
+{
+ auto *context = new llvm::LLVMContext();
+
+ for (uint node_id : graph->node_ids()) {
+ SharedFunction &fn = graph->function_of_node(node_id);
+ if (fn->has_body<TupleCallBody>()) {
+ continue;
+ }
+
+ if (fn->has_body<LazyInTupleCallBody>()) {
+ derive_TupleCallBody_from_LazyInTupleCallBody(fn);
+ }
+
+ if (fn->has_body<LLVMBuildIRBody>()) {
+ derive_TupleCallBody_from_LLVMBuildIRBody(fn, *context);
+ }
+ }
+}
+
class ExecuteGraph : public TupleCallBody {
private:
FunctionGraph m_fgraph;
@@ -10,25 +30,9 @@ class ExecuteGraph : public TupleCallBody {
DataFlowGraph *m_graph;
public:
- ExecuteGraph(const FunctionGraph &function_graph)
+ ExecuteGraph(FunctionGraph &function_graph)
: m_fgraph(function_graph), m_graph(function_graph.graph().ptr())
{
- auto *context = new llvm::LLVMContext();
-
- for (uint node : m_graph->node_ids()) {
- SharedFunction &fn = m_graph->function_of_node(node);
- if (fn->has_body<TupleCallBody>()) {
- continue;
- }
-
- if (fn->has_body<LazyInTupleCallBody>()) {
- derive_TupleCallBody_from_LazyInTupleCallBody(fn);
- }
-
- if (fn->has_body<LLVMBuildIRBody>()) {
- derive_TupleCallBody_from_LLVMBuildIRBody(fn, *context);
- }
- }
}
void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx) const override
@@ -72,6 +76,7 @@ class ExecuteGraph : public TupleCallBody {
void fgraph_add_TupleCallBody(SharedFunction &fn, FunctionGraph &fgraph)
{
+ try_ensure_tuple_call_bodies(fgraph.graph());
fn->add_body(new ExecuteGraph(fgraph));
}
diff --git a/source/blender/functions/core/function_graph.hpp b/source/blender/functions/core/function_graph.hpp
index 67e5ca8a023..1aa36119fd9 100644
--- a/source/blender/functions/core/function_graph.hpp
+++ b/source/blender/functions/core/function_graph.hpp
@@ -23,6 +23,11 @@ class FunctionGraph {
return m_graph;
}
+ SharedDataFlowGraph &graph()
+ {
+ return m_graph;
+ }
+
const DFGraphSocketVector &inputs() const
{
return m_inputs;
More information about the Bf-blender-cvs
mailing list