[Bf-blender-cvs] [e57c3996bda] functions: store possible tuple meta in tuple call body
Jacques Lucke
noreply at git.blender.org
Sun Mar 10 13:14:25 CET 2019
Commit: e57c3996bda06bdc2bee3cf133e7c275bd27fd9b
Author: Jacques Lucke
Date: Sun Mar 10 10:26:19 2019 +0100
Branches: functions
https://developer.blender.org/rBe57c3996bda06bdc2bee3cf133e7c275bd27fd9b
store possible tuple meta in tuple call body
===================================================================
M source/blender/blenlib/BLI_shared.hpp
M source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
M source/blender/functions/backends/tuple_call/tuple_call.cpp
M source/blender/functions/backends/tuple_call/tuple_call.hpp
M source/blender/functions/core/data_flow_graph.hpp
M source/blender/functions/core/function.hpp
===================================================================
diff --git a/source/blender/blenlib/BLI_shared.hpp b/source/blender/blenlib/BLI_shared.hpp
index 2663bfb10dd..029494aa385 100644
--- a/source/blender/blenlib/BLI_shared.hpp
+++ b/source/blender/blenlib/BLI_shared.hpp
@@ -42,7 +42,6 @@ namespace BLI {
private:
T *m_object;
- AutoRefCount() = delete;
AutoRefCount(T *object)
: m_object(object) {}
@@ -57,6 +56,9 @@ namespace BLI {
}
public:
+ AutoRefCount()
+ : AutoRefCount(new T()) {}
+
template<typename ...Args>
static AutoRefCount<T> New(Args&&... args)
{
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 6d61cd6cef0..e1cb90d8880 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -33,26 +33,28 @@ namespace FN {
}
else {
Node *node = socket.node();
- const Signature &signature = node->signature();
+ TupleCallBody *body = this->get_node_body(node);
- auto meta_in = SharedTupleMeta::New(signature.input_types());
- auto meta_out = SharedTupleMeta::New(signature.output_types());
+ FN_TUPLE_STACK_ALLOC(tmp_in, body->meta_in());
+ FN_TUPLE_STACK_ALLOC(tmp_out, body->meta_out());
- FN_TUPLE_STACK_ALLOC(tmp_in, meta_in);
- FN_TUPLE_STACK_ALLOC(tmp_out, meta_out);
-
- for (uint i = 0; i < signature.inputs().size(); i++) {
+ for (uint i = 0; i < node->input_amount(); i++) {
this->compute_socket(fn_in, tmp_in, i, node->input(i));
}
- if (!node->function()->has_body<TupleCallBody>()) {
- derive_TupleCallBody_from_LLVMBuildIRBody(node->function(), *(new llvm::LLVMContext()));
- }
- TupleCallBody *body = node->function()->body<TupleCallBody>();
+
body->call(tmp_in, tmp_out);
Tuple::copy_element(tmp_out, socket.index(), out, out_index);
}
}
+
+ TupleCallBody *get_node_body(Node *node) const
+ {
+ if (!node->function()->has_body<TupleCallBody>()) {
+ derive_TupleCallBody_from_LLVMBuildIRBody(node->function(), *(new llvm::LLVMContext()));
+ }
+ return node->function()->body<TupleCallBody>();
+ }
};
void fgraph_add_TupleCallBody(
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.cpp b/source/blender/functions/backends/tuple_call/tuple_call.cpp
index dd34f687973..0ce79b1590b 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.cpp
@@ -18,4 +18,10 @@ namespace FN {
fn_in.init_default_all();
}
+ void TupleCallBody::owner_init_post()
+ {
+ m_meta_in = SharedTupleMeta::New(this->owner()->signature().input_types());
+ m_meta_out = SharedTupleMeta::New(this->owner()->signature().output_types());
+ }
+
} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index f409cf1e047..ecffd787010 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -5,6 +5,16 @@
namespace FN {
class TupleCallBody : public FunctionBody {
+ private:
+ SharedTupleMeta m_meta_in;
+ SharedTupleMeta m_meta_out;
+
+ protected:
+ void owner_init_post() override;
+
+ TupleCallBody()
+ : FunctionBody() {}
+
public:
static const char *identifier_in_composition();
static void free_self(void *value);
@@ -13,6 +23,16 @@ namespace FN {
virtual void call(Tuple &fn_in, Tuple &fn_out) const = 0;
virtual void init_defaults(Tuple &fn_in) const;
+
+ SharedTupleMeta &meta_in()
+ {
+ return m_meta_in;
+ }
+
+ SharedTupleMeta &meta_out()
+ {
+ return m_meta_out;
+ }
};
} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index a49cf52c770..7b8e47ffe36 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -87,6 +87,16 @@ namespace FN {
return this->function()->signature();
}
+ uint input_amount() const
+ {
+ return this->signature().inputs().size();
+ }
+
+ uint output_amount() const
+ {
+ return this->signature().outputs().size();
+ }
+
class SocketIterator {
private:
Node *m_node;
diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index 7f0f9cf6544..d40c374f79a 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -13,11 +13,17 @@ namespace FN {
void set_owner(Function *fn)
{
m_owner = fn;
+ this->owner_init_post();
}
friend class Function;
+ protected:
+ virtual void owner_init_post() {}
+
public:
+ virtual ~FunctionBody() {}
+
Function *owner() const
{
return m_owner;
More information about the Bf-blender-cvs
mailing list