[Bf-blender-cvs] [89957b1] depsgraph_refactor: use proper evaluation context instead of enum flag

Sergey Sharybin noreply at git.blender.org
Mon Oct 13 16:20:54 CEST 2014


Commit: 89957b1f1d7be121613e3f54d691bdc6a9fd1efb
Author: Sergey Sharybin
Date:   Mon Oct 13 16:18:38 2014 +0200
Branches: depsgraph_refactor
https://developer.blender.org/rB89957b1f1d7be121613e3f54d691bdc6a9fd1efb

use proper evaluation context instead of enum flag

Depsgraph evaluation would need to have proper evaluation context in the
future anyway, where some COW data might be stored. it was also kind of
weird to have another set of enum flags defining how evaluation should
happen.

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

M	source/blender/blenkernel/intern/scene.c
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_debug.cpp
M	source/blender/depsgraph/intern/depsgraph_debug.h
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_eval.h
M	source/blender/depsgraph/intern/depsnode_component.h
M	source/blender/depsgraph/util/depsgraph_util_task.cpp
M	source/blender/depsgraph/util/depsgraph_util_task.h
M	source/blender/makesrna/intern/rna_depsgraph.c

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 4aed360..fad1f31 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1697,7 +1697,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
 	else {
 		/* new depsgraph */
 		BLI_assert(scene->depsgraph);
-		DEG_evaluate_on_refresh(scene->depsgraph, eval_ctx->mode == DAG_EVAL_RENDER ? DEG_EVALUATION_CONTEXT_RENDER : DEG_EVALUATION_CONTEXT_VIEWPORT);
+		DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph);
 	}
 }
 
@@ -1792,7 +1792,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
 		float ctime = BKE_scene_frame_get(sce);
 		/* new depsgraph */
 		BLI_assert(sce->depsgraph);
-		DEG_evaluate_on_framechange(sce->depsgraph, eval_ctx->mode == DAG_EVAL_RENDER ? DEG_EVALUATION_CONTEXT_RENDER : DEG_EVALUATION_CONTEXT_VIEWPORT, ctime);
+		DEG_evaluate_on_framechange(eval_ctx, sce->depsgraph, ctime);
 	}
 }
 
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 4a06a6b..d3041f9 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -55,6 +55,7 @@ typedef struct Depsgraph Depsgraph;
 
 /* ------------------------------------------------ */
 
+struct EvaluationContext;
 struct Main;
 struct Scene;
 
@@ -123,36 +124,21 @@ void DEG_graph_clear_tags(Depsgraph *graph);
 /* ************************************************ */
 /* Evaluation Engine API */
 
-/* Role of evaluation context
- * Describes what each context is to be used for evaluating
- */
-typedef enum eEvaluationContextType {
-	/* All Contexts - Not a proper role, but is used when passing args to functions */
-	DEG_ALL_EVALUATION_CONTEXTS     = -1,
-	
-	/* Viewport Display */
-	DEG_EVALUATION_CONTEXT_VIEWPORT = 0,
-	/* Render Engine DB Conversion */
-	DEG_EVALUATION_CONTEXT_RENDER   = 1,
-	/* Background baking operation */
-	DEG_EVALUATION_CONTEXT_BAKE     = 2,
-	
-	/* Maximum number of support evaluation contexts (Always as last) */
-	DEG_MAX_EVALUATION_CONTEXTS
-} eEvaluationContextType;
-
 /* ----------------------------------------------- */
 
 /* Frame changed recalculation entrypoint 
  * < context_type: context to perform evaluation for
  * < ctime: (frame) new frame to evaluate values on
  */
-void DEG_evaluate_on_framechange(Depsgraph *graph, eEvaluationContextType context_type, double ctime);
+void DEG_evaluate_on_framechange(struct EvaluationContext *eval_ctx,
+                                 Depsgraph *graph,
+                                 double ctime);
 
 /* Data changed recalculation entrypoint 
  * < context_type: context to perform evaluation for
  */
-void DEG_evaluate_on_refresh(Depsgraph *graph, eEvaluationContextType context_type);
+void DEG_evaluate_on_refresh(struct EvaluationContext *eval_ctx,
+                             Depsgraph *graph);
 
 /* ----------------------------------------------- */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 143d701..69e84ae 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -721,18 +721,18 @@ static void times_add(DepsgraphStatsTimes &times, float time)
 	times.duration_last += time;
 }
 
-void DepsgraphDebug::eval_begin(eEvaluationContextType context_type)
+void DepsgraphDebug::eval_begin(const EvaluationContext *eval_ctx)
 {
 	verify_stats(&U.depsgraph_settings);
 	reset_stats();
 }
 
-void DepsgraphDebug::eval_end(eEvaluationContextType context_type)
+void DepsgraphDebug::eval_end(const EvaluationContext *eval_ctx)
 {
 	WM_main_add_notifier(NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
 }
 
-void DepsgraphDebug::eval_step(eEvaluationContextType context_type, const char *message)
+void DepsgraphDebug::eval_step(const EvaluationContext *eval_ctx, const char *message)
 {
 #ifdef DEG_DEBUG_BUILD
 	if (deg_debug_eval_cb)
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.h b/source/blender/depsgraph/intern/depsgraph_debug.h
index 3afdc5e..4d1ff89 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.h
+++ b/source/blender/depsgraph/intern/depsgraph_debug.h
@@ -47,6 +47,7 @@ struct DepsgraphStats;
 struct DepsgraphStatsID;
 struct DepsgraphStatsComponent;
 struct DepsgraphSettings;
+struct EvaluationContext;
 struct OperationDepsNode;
 
 struct Depsgraph;
@@ -60,9 +61,9 @@ struct DepsgraphDebug {
 	static void verify_stats(DepsgraphSettings *settings);
 	static void reset_stats();
 	
-	static void eval_begin(eEvaluationContextType context_type);
-	static void eval_end(eEvaluationContextType context_type);
-	static void eval_step(eEvaluationContextType context_type, const char *message);
+	static void eval_begin(const EvaluationContext *eval_ctx);
+	static void eval_end(const EvaluationContext *eval_ctx);
+	static void eval_step(const EvaluationContext *eval_ctx, const char *message);
 	
 	static void task_started(const OperationDepsNode *node);
 	static void task_completed(const OperationDepsNode *node, double time);
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index 249f52f..d9541ae 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -153,7 +153,7 @@ static void calculate_eval_priority(OperationDepsNode *node)
 		node->eval_priority = 0.0f;
 }
 
-static void schedule_graph(TaskPool *pool, Depsgraph *graph, eEvaluationContextType context_type)
+static void schedule_graph(TaskPool *pool, EvaluationContext *eval_ctx, Depsgraph *graph)
 {
 	BLI_spin_lock(&threaded_update_lock);
 	for (Depsgraph::OperationNodes::const_iterator it = graph->operations.begin(); it != graph->operations.end(); ++it) {
@@ -167,7 +167,7 @@ static void schedule_graph(TaskPool *pool, Depsgraph *graph, eEvaluationContextT
 	BLI_spin_unlock(&threaded_update_lock);
 }
 
-void deg_schedule_children(TaskPool *pool, Depsgraph *graph, eEvaluationContextType context_type, OperationDepsNode *node)
+void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx, Depsgraph *graph, OperationDepsNode *node)
 {
 	for (OperationDepsNode::Relations::const_iterator it = node->outlinks.begin(); it != node->outlinks.end(); ++it) {
 		DepsRelation *rel = *it;
@@ -196,15 +196,15 @@ void deg_schedule_children(TaskPool *pool, Depsgraph *graph, eEvaluationContextT
  * ! This is usually done as part of main loop, but may also be 
  *   called from frame-change update
  */
-void DEG_evaluate_on_refresh(Depsgraph *graph, eEvaluationContextType context_type)
+void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
 {
 	/* generate base evaluation context, upon which all the others are derived... */
 	// TODO: this needs both main and scene access...
 	
 	/* XXX could use a separate pool for each eval context */
 	DepsgraphEvalState state;
+	state.eval_ctx = eval_ctx;
 	state.graph = graph;
-	state.context_type = context_type;
 
 	TaskScheduler *task_scheduler = BLI_task_scheduler_get();
 	TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &state);
@@ -227,21 +227,23 @@ void DEG_evaluate_on_refresh(Depsgraph *graph, eEvaluationContextType context_ty
 		calculate_eval_priority(node);
 	}
 	
-	DepsgraphDebug::eval_begin(context_type);
+	DepsgraphDebug::eval_begin(eval_ctx);
 	
-	schedule_graph(task_pool, graph, context_type);
+	schedule_graph(task_pool, eval_ctx, graph);
 	
 	BLI_task_pool_work_and_wait(task_pool);
 	BLI_task_pool_free(task_pool);
 	
-	DepsgraphDebug::eval_end(context_type);
+	DepsgraphDebug::eval_end(eval_ctx);
 	
 	/* clear any uncleared tags - just in case */
 	DEG_graph_clear_tags(graph);
 }
 
 /* Frame-change happened for root scene that graph belongs to */
-void DEG_evaluate_on_framechange(Depsgraph *graph, eEvaluationContextType context_type, double ctime)
+void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx,
+                                 Depsgraph *graph,
+                                 double ctime)
 {
 	/* update time on primary timesource */
 	TimeSourceDepsNode *tsrc = graph->find_time_source();
@@ -252,7 +254,7 @@ void DEG_evaluate_on_framechange(Depsgraph *graph, eEvaluationContextType contex
 #endif
 	
 	/* perform recalculation updates */
-	DEG_evaluate_on_refresh(graph, context_type);
+	DEG_evaluate_on_refresh(eval_ctx, graph);
 }
 
 /* *************************************************** */
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.h b/source/blender/depsgraph/intern/depsgraph_eval.h
index 9f4be5d..ad5b733 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.h
+++ b/source/blender/depsgraph/intern/depsgraph_eval.h
@@ -137,6 +137,6 @@ typedef struct DEG_PoseContext {
 struct Depsgraph;
 struct OperationDepsNode;
 struct Taskpool;
-void deg_schedule_children(TaskPool *pool, Depsgraph *graph, eEvaluationContextType context_type, OperationDepsNode *node);
+void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx, Depsgraph *graph, OperationDepsNode *node);
 
 #endif // __DEPSGRAPH_EVAL_TYPES_H__
diff --git a/source/blender/depsgraph/intern/depsnode_component.h b/source/blender/depsgraph/intern/depsnode_component.h
index 157dc96..4ee31b4 100644
--- a/source/blender/depsgraph/intern/depsnode_component.h
+++ b/source/blender/depsgraph/intern/depsnode_component.h
@@ -40,6 +40,7 @@ struct bPoseChannel;
 
 struct Depsgraph;
 struct DepsgraphCopyContext;
+struct EvaluationContext;
 struct OperationDepsNode;
 struct BoneComponentDepsNode;
 
@@ -72,11 +73,11 @@ struct ComponentDepsNode : public DepsNode {
 	/* Evaluation Context Management .................. */
 	
 	/* Initialise component's evaluation context used for the specified purpose */
-	virtual bool eval_context_init(eEvaluationContextType context_type) { return false; }
+	virtual bool eval_context_init(EvaluationContext *eval_ctx) { return false; }
 	/* Free data in component's evaluation context which is used for the specified purpose 
 	 * NOTE: this does not free the actual context in question
 	 */
-	virtual 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list