[Bf-blender-cvs] [ac5f92c] depsgraph_refactor: Moved the depsgraph eval simulation into the task function, instead of running it in the callback stubs.
Lukas Tönne
noreply at git.blender.org
Wed Jun 4 13:01:16 CEST 2014
Commit: ac5f92c393ec82059d8782430571816038925d1d
Author: Lukas Tönne
Date: Wed Jun 4 09:18:44 2014 +0200
https://developer.blender.org/rBac5f92c393ec82059d8782430571816038925d1d
Moved the depsgraph eval simulation into the task function, instead of
running it in the callback stubs.
It is now properly toggled by the debug_value magic numbers (14228 for
new depsgraph evaluation, 12345 for simulating with the new depsgraph
instead of using the operation callbacks).
===================================================================
M source/blender/depsgraph/intern/depsgraph_eval.cpp
M source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M source/blender/depsgraph/intern/stubs.h
M source/blender/depsgraph/util/depsgraph_util_task.cpp
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index e1e7e41..9d82486 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -67,9 +67,6 @@ extern "C" {
#include "depsgraph_intern.h"
#include "depsgraph_debug.h"
-/* XXX for simulation, remove later */
-#include "stubs.h"
-
eDEG_EvalMode DEG_get_eval_mode(void)
{
switch (G.debug_value) {
@@ -95,7 +92,6 @@ void DEG_set_eval_mode(eDEG_EvalMode mode)
void DEG_threaded_init(void)
{
DepsgraphTaskScheduler::init();
- deg_simulate_eval_init();
}
/* Free threading lock - called during application shutdown */
@@ -104,7 +100,6 @@ void DEG_threaded_exit(void)
DepsgraphDebug::stats_free();
DepsgraphTaskScheduler::exit();
- deg_simulate_eval_free();
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 399b8cc..95ca9d2 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -60,67 +60,33 @@ extern "C" {
#include "depsgraph_util_map.h"
#include "stubs.h" // XXX: THIS MUST BE REMOVED WHEN THE DEPSGRAPH REFACTOR IS DONE
-extern "C" {
-#include "BLI_rand.h"
-#include "PIL_time.h"
-}
-
-#ifdef DEG_SIMULATE_EVAL
-
-static RNG *deg_sim_eval_rng = NULL;
-
-void deg_simulate_eval_init()
-{
- deg_sim_eval_rng = BLI_rng_new((unsigned int)(PIL_check_seconds_timer() * 0x7FFFFFFF));
-}
-
-void deg_simulate_eval_free()
-{
- BLI_rng_free(deg_sim_eval_rng);
- deg_sim_eval_rng = NULL;
-}
-
-#define SIMULATE_WORK(min, max) { \
- int r = BLI_rng_get_int(deg_sim_eval_rng); \
- int ms = (int)(min) + r % ((int)(max) - (int)(min)); \
- PIL_sleep_ms(ms); \
-}
-
-#else /* DEG_SIMULATE_EVAL */
-
-void deg_simulate_eval_init() {}
-void deg_simulate_eval_free() {}
-
-#define SIMULATE_WORK(min, max) void(0);
-
-#endif /* DEG_SIMULATE_EVAL */
-void BKE_animsys_eval_driver(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_animsys_eval_driver(void *context, void *item) {}
-void BKE_constraints_evaluate(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_pose_iktree_evaluate(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_pose_splineik_evaluate(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_pose_eval_bone(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_constraints_evaluate(void *context, void *item) {}
+void BKE_pose_iktree_evaluate(void *context, void *item) {}
+void BKE_pose_splineik_evaluate(void *context, void *item) {}
+void BKE_pose_eval_bone(void *context, void *item) {}
-void BKE_pose_rebuild_op(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_pose_eval_init(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_pose_eval_flush(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_pose_rebuild_op(void *context, void *item) {}
+void BKE_pose_eval_init(void *context, void *item) {}
+void BKE_pose_eval_flush(void *context, void *item) {}
-void BKE_particle_system_eval(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_particle_system_eval(void *context, void *item) {}
-void BKE_rigidbody_rebuild_sim(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_rigidbody_eval_simulation(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_rigidbody_object_sync_transforms(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_rigidbody_rebuild_sim(void *context, void *item) {}
+void BKE_rigidbody_eval_simulation(void *context, void *item) {}
+void BKE_rigidbody_object_sync_transforms(void *context, void *item) {}
-void BKE_object_eval_local_transform(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_object_eval_parent(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_object_eval_modifier(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_object_eval_local_transform(void *context, void *item) {}
+void BKE_object_eval_parent(void *context, void *item) {}
+void BKE_object_eval_modifier(void *context, void *item) {}
-void BKE_mesh_eval_geometry(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_mball_eval_geometry(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_curve_eval_geometry(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_curve_eval_path(void *context, void *item) { SIMULATE_WORK(20,30); }
-void BKE_lattice_eval_geometry(void *context, void *item) { SIMULATE_WORK(20,30); }
+void BKE_mesh_eval_geometry(void *context, void *item) {}
+void BKE_mball_eval_geometry(void *context, void *item) {}
+void BKE_curve_eval_geometry(void *context, void *item) {}
+void BKE_curve_eval_path(void *context, void *item) {}
+void BKE_lattice_eval_geometry(void *context, void *item) {}
const string deg_op_name_object_parent = "BKE_object_eval_parent";
const string deg_op_name_object_local_transform = "BKE_object_eval_local_transform";
diff --git a/source/blender/depsgraph/intern/stubs.h b/source/blender/depsgraph/intern/stubs.h
index 405d7e3..555055c 100644
--- a/source/blender/depsgraph/intern/stubs.h
+++ b/source/blender/depsgraph/intern/stubs.h
@@ -10,12 +10,6 @@
#pragma message("DEPSGRAPH PORTING XXX: There are still some undefined stubs")
-/* spend random time in operation functions to simulate work */
-#define DEG_SIMULATE_EVAL
-
-void deg_simulate_eval_init();
-void deg_simulate_eval_free();
-
void BKE_animsys_eval_driver(void *context, void *item);
void BKE_constraints_evaluate(void *context, void *item);
diff --git a/source/blender/depsgraph/util/depsgraph_util_task.cpp b/source/blender/depsgraph/util/depsgraph_util_task.cpp
index 9544bb1..58a1897 100644
--- a/source/blender/depsgraph/util/depsgraph_util_task.cpp
+++ b/source/blender/depsgraph/util/depsgraph_util_task.cpp
@@ -26,9 +26,12 @@
#include <stdlib.h>
#include "BLI_utildefines.h"
-
#include "PIL_time.h"
+extern "C" {
+#include "BLI_rand.h" /* XXX for eval simulation only, remove eventually */
+}
+
#include "depsgraph_debug.h"
#include "depsnode_component.h"
@@ -36,6 +39,21 @@
/* Task */
+/* **** eval simulation **** */
+static RNG *deg_eval_sim_rng = NULL;
+
+static void deg_eval_sim_init()
+{
+ deg_eval_sim_rng = BLI_rng_new((unsigned int)(PIL_check_seconds_timer() * 0x7FFFFFFF));
+}
+
+static void deg_eval_sim_free()
+{
+ BLI_rng_free(deg_eval_sim_rng);
+ deg_eval_sim_rng = NULL;
+}
+/* ******** */
+
DepsgraphTask::DepsgraphTask(Depsgraph *graph_, OperationDepsNode *node_, eEvaluationContextType context_type_) :
graph(graph_),
node(node_),
@@ -62,10 +80,21 @@ void DepsgraphTask::run()
double start_time = PIL_check_seconds_timer();
DepsgraphDebug::task_started(*this);
- /* should only be the case for NOOPs, which never get to this point */
- BLI_assert(node->evaluate);
- /* perform operation */
- node->evaluate(context, item);
+ if (DEG_get_eval_mode() == DEG_EVAL_MODE_SIM) {
+ /* simulate work, but actually just take a nap here ... */
+
+ int min = 20, max = 30; /* default siesta duration in milliseconds */
+
+ int r = BLI_rng_get_int(deg_eval_sim_rng);
+ int ms = (int)(min) + r % ((int)(max) - (int)(min));
+ PIL_sleep_ms(ms);
+ }
+ else {
+ /* should only be the case for NOOPs, which never get to this point */
+ BLI_assert(node->evaluate);
+ /* perform operation */
+ node->evaluate(context, item);
+ }
/* note how long this took */
double end_time = PIL_check_seconds_timer();
@@ -247,6 +276,8 @@ void DepsgraphTaskScheduler::init(int num_threads)
for(size_t i = 0; i < threads.size(); i++)
threads[i] = new Thread(&DepsgraphTaskScheduler::thread_run, i);
+
+ deg_eval_sim_init();
}
void DepsgraphTaskScheduler::exit()
@@ -262,6 +293,8 @@ void DepsgraphTaskScheduler::exit()
delete t;
}
threads.clear();
+
+ deg_eval_sim_free();
}
bool DepsgraphTaskScheduler::thread_wait_pop(Entry& entry)
More information about the Bf-blender-cvs
mailing list