[Bf-blender-cvs] [f822be1] depsgraph_refactor: Update simulation: Spend random sleep time in depsgraph operation stubs, to simulate actual work and provide a testbed for the scheduler.

Lukas Tönne noreply at git.blender.org
Tue May 27 09:05:12 CEST 2014


Commit: f822be18652af00884a361a6d588dea82f02297d
Author: Lukas Tönne
Date:   Tue May 27 08:56:54 2014 +0200
https://developer.blender.org/rBf822be18652af00884a361a6d588dea82f02297d

Update simulation: Spend random sleep time in depsgraph operation stubs,
to simulate actual work and provide a testbed for the scheduler.

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

M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M	source/blender/depsgraph/intern/stubs.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index 24a23ea..2ea768d 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -66,6 +66,9 @@ extern "C" {
 #include "depsgraph_intern.h"
 #include "depsgraph_debug.h"
 
+/* XXX for simulation, remove later */
+#include "stubs.h"
+
 /* *************************************************** */
 /* Multi-Threaded Evaluation Internals */
 
@@ -73,12 +76,14 @@ extern "C" {
 void DEG_threaded_init(void)
 {
 	DepsgraphTaskScheduler::init();
+	deg_simulate_eval_init();
 }
 
 /* Free threading lock - called during application shutdown */
 void DEG_threaded_exit(void)
 {
 	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 95ca9d2..399b8cc 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -60,33 +60,67 @@ 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) {}
+void BKE_animsys_eval_driver(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_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_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_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_particle_system_eval(void *context, void *item) {}
+void BKE_particle_system_eval(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_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_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_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_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) {}
+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); }
 
 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 555055c..405d7e3 100644
--- a/source/blender/depsgraph/intern/stubs.h
+++ b/source/blender/depsgraph/intern/stubs.h
@@ -10,6 +10,12 @@
 
 #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);




More information about the Bf-blender-cvs mailing list