[Bf-blender-cvs] [66e4eb795d4] functions: higher level macro for tuple allocation

Jacques Lucke noreply at git.blender.org
Sat Apr 6 18:47:25 CEST 2019


Commit: 66e4eb795d48f00612513f6b24682a9348521829
Author: Jacques Lucke
Date:   Sat Apr 6 18:12:48 2019 +0200
Branches: functions
https://developer.blender.org/rB66e4eb795d48f00612513f6b24682a9348521829

higher level macro for tuple allocation

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

M	source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
M	source/blender/functions/backends/tuple_call/tuple_call.hpp
M	source/blender/functions/functions/auto_vectorization.cpp

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

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 46d77c5208d..ada61e5867a 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -394,8 +394,7 @@ namespace FN {
 				SharedFunction &fn = node->function();
 				TupleCallBody *body = fn->body<TupleCallBody>();
 
-				FN_TUPLE_STACK_ALLOC(tmp_in, body->meta_in());
-				FN_TUPLE_STACK_ALLOC(tmp_out, body->meta_out());
+				FN_TUPLE_CALL_ALLOC_TUPLES(body, tmp_in, tmp_out);
 
 				for (uint i = 0; i < node->input_amount(); i++) {
 					this->compute_socket(fn_in, tmp_in, i, node->input(i), ctx);
@@ -501,8 +500,7 @@ namespace FN {
 				if (fn->has_body<LazyInTupleCallBody>()) {
 					auto *body = node->function()->body<LazyInTupleCallBody>();
 
-					FN_TUPLE_STACK_ALLOC(fn_in, body->meta_in());
-					FN_TUPLE_STACK_ALLOC(fn_out, body->meta_out());
+					FN_TUPLE_CALL_ALLOC_TUPLES(body, fn_in, fn_out);
 
 					for (uint input_index : body->always_required()) {
 						Socket input_socket = node->input(input_index);
@@ -540,8 +538,7 @@ namespace FN {
 				else if (fn->has_body<TupleCallBody>()) {
 					auto *body = node->function()->body<TupleCallBody>();
 
-					FN_TUPLE_STACK_ALLOC(fn_in, body->meta_in());
-					FN_TUPLE_STACK_ALLOC(fn_out, body->meta_out());
+					FN_TUPLE_CALL_ALLOC_TUPLES(body, fn_in, fn_out);
 
 					for (uint input_index = 0; input_index < node->input_amount(); input_index++) {
 						Socket input_socket = node->input(input_index);
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index 6f124b0da4a..357417097c9 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -101,4 +101,8 @@ namespace FN {
 		virtual void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx, LazyState &state) const = 0;
 	};
 
-} /* namespace FN */
\ No newline at end of file
+} /* namespace FN */
+
+#define FN_TUPLE_CALL_ALLOC_TUPLES(body, name_in, name_out) \
+	FN_TUPLE_STACK_ALLOC(name_in, body->meta_in()); \
+	FN_TUPLE_STACK_ALLOC(name_out, body->meta_out());
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index 9c3c426dd36..1300c37b670 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -68,8 +68,7 @@ namespace FN { namespace Functions {
 
 			this->initialize_empty_lists(fn_out, ctx);
 
-			FN_TUPLE_STACK_ALLOC(main_in, m_main_body->meta_in());
-			FN_TUPLE_STACK_ALLOC(main_out, m_main_body->meta_out());
+			FN_TUPLE_CALL_ALLOC_TUPLES(m_main_body, main_in, main_out);
 
 			for (uint iteration = 0; iteration < max_length; iteration++) {
 				uint list_index = 0;
@@ -126,8 +125,8 @@ namespace FN { namespace Functions {
 			TupleCallBody *body = m_get_element_bodies[list_index];
 
 			uint load_index = iteration % list_length;
-			FN_TUPLE_STACK_ALLOC(get_element_in, body->meta_in());
-			FN_TUPLE_STACK_ALLOC(get_element_out, body->meta_out());
+
+			FN_TUPLE_CALL_ALLOC_TUPLES(body, get_element_in, get_element_out);
 
 			Tuple::copy_element(fn_in, index, get_element_in, 0);
 			get_element_in.set<uint>(1, load_index);
@@ -149,9 +148,7 @@ namespace FN { namespace Functions {
 		{
 			TupleCallBody *body = m_create_empty_bodies[index];
 
-			FN_TUPLE_STACK_ALLOC(create_list_in, body->meta_in());
-			FN_TUPLE_STACK_ALLOC(create_list_out, body->meta_out());
-
+			FN_TUPLE_CALL_ALLOC_TUPLES(body, create_list_in, create_list_out);
 			body->call__setup_stack(create_list_in, create_list_out, ctx);
 
 			Tuple::relocate_element(create_list_out, 0, fn_out, index);
@@ -161,8 +158,7 @@ namespace FN { namespace Functions {
 		{
 			TupleCallBody *body = m_append_bodies[index];
 
-			FN_TUPLE_STACK_ALLOC(append_in, body->meta_in());
-			FN_TUPLE_STACK_ALLOC(append_out, body->meta_out());
+			FN_TUPLE_CALL_ALLOC_TUPLES(body, append_in, append_out);
 
 			Tuple::relocate_element(fn_out, index, append_in, 0);
 			Tuple::relocate_element(main_out, index, append_in, 1);



More information about the Bf-blender-cvs mailing list