Commit: 6c496908471f34daf783f3553f91f86b77501cb5
Author: Jacques Lucke
Date:   Sun Mar 10 13:11:02 2019 +0100
Branches: functions
https://developer.blender.org/rB6c496908471f34daf783f3553f91f86b77501cb5

also allow heap allocation for tuples in C

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

M       source/blender/functions/FN-C.h
M       
source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
M       source/blender/modifiers/intern/MOD_displace.c
M       source/blender/modifiers/intern/MOD_functiondeform.c

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

diff --git a/source/blender/functions/FN-C.h b/source/blender/functions/FN-C.h
index e97b8743959..c09c4c95281 100644
--- a/source/blender/functions/FN-C.h
+++ b/source/blender/functions/FN-C.h
@@ -77,6 +77,13 @@ void fn_tuple_destruct(FnTuple tuple);
        fn_tuple_destruct(fn_in); \
        fn_tuple_destruct(fn_out);
 
+#define FN_TUPLE_CALL_PREPARE_HEAP(body, fn_in, fn_out) \
+       FnTuple fn_in = FN_tuple_for_input(body); \
+       FnTuple fn_out = FN_tuple_for_output(body); \
+
+#define FN_TUPLE_CALL_DESTRUCT_HEAP(body, fn_in, fn_out) \
+       FN_tuple_free(fn_in); \
+       FN_tuple_free(fn_out);
 
 /*************** Dependencies ****************/
 
diff --git 
a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp 
b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
index b2493657b3f..45f289ae3a7 100644
--- a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
@@ -19,9 +19,9 @@ namespace FN { namespace DataFlowNodes {
 
                auto fn = SharedFunction::New(btree->id.name, 
fgraph.signature());
                fgraph_add_DependenciesBody(fn, fgraph);
-               fgraph_add_TupleCallBody(fn, fgraph);
-               //fgraph_add_LLVMBuildIRBody(fn, fgraph);
-               //derive_TupleCallBody_from_LLVMBuildIRBody(fn, *(new 
llvm::LLVMContext()));
+               //fgraph_add_TupleCallBody(fn, fgraph);
+               fgraph_add_LLVMBuildIRBody(fn, fgraph);
+               derive_TupleCallBody_from_LLVMBuildIRBody(fn, *(new 
llvm::LLVMContext()));
                return fn;
        }
 
diff --git a/source/blender/modifiers/intern/MOD_displace.c 
b/source/blender/modifiers/intern/MOD_displace.c
index 0df669a8f6d..f472f5c8d85 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -27,6 +27,8 @@
 #include "BLI_math.h"
 #include "BLI_task.h"
 
+#include "PIL_time_utildefines.h"
+
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
@@ -221,8 +223,9 @@ static void displaceModifier_do_task(
 
        if (data->calc_weight_func) {
                FnTupleCallBody body = 
FN_tuple_call_get(data->calc_weight_func);
-               FnTuple fn_in = FN_tuple_for_input(body);
-               FnTuple fn_out = FN_tuple_for_output(body);
+               BLI_assert(body);
+
+               FN_TUPLE_CALL_PREPARE_STACK(body, fn_in, fn_out);
 
                FN_tuple_set_float_vector_3(fn_in, 0, vertexCos[iter]);
                FN_tuple_set_int32(fn_in, 1, iter);
@@ -231,8 +234,7 @@ static void displaceModifier_do_task(
 
                weight = FN_tuple_get_float(fn_out, 0);
 
-               FN_tuple_free(fn_in);
-               FN_tuple_free(fn_out);
+               FN_TUPLE_CALL_DESTRUCT_STACK(body, fn_in, fn_out);
        }
 
        if (weight == 0.0f) {
@@ -390,6 +392,8 @@ static void displaceModifier_do(
        }
        data.calc_weight_func = getCurrentFunction(dmd);
 
+       TIMEIT_START(displace_timer);
+
        ParallelRangeSettings settings;
        BLI_parallel_range_settings_defaults(&settings);
        settings.use_threading = (numVerts > 512);
@@ -398,6 +402,8 @@ static void displaceModifier_do(
                                displaceModifier_do_task,
                                &settings);
 
+       TIMEIT_END(displace_timer);
+
        if (data.pool != NULL) {
                BKE_image_pool_free(data.pool);
        }
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c 
b/source/blender/modifiers/intern/MOD_functiondeform.c
index d483bbf7799..5f8dd89f69b 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -80,7 +80,7 @@ static void do_deformation(
        FnTupleCallBody body = FN_tuple_call_get(fn);
        BLI_assert(body);
 
-       FN_TUPLE_CALL_PREPARE_STACK(body, fn_in, fn_out);
+       FN_TUPLE_CALL_PREPARE_HEAP(body, fn_in, fn_out);
 
        clock_t start = clock();
 
@@ -97,7 +97,7 @@ static void do_deformation(
        clock_t end = clock();
        printf("Time taken: %f s\n", (float)(end - start) / 
(float)CLOCKS_PER_SEC);
 
-       FN_TUPLE_CALL_DESTRUCT_STACK(body, fn_in, fn_out);
+       FN_TUPLE_CALL_DESTRUCT_HEAP(body, fn_in, fn_out);
        FN_function_free(fn);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to