[Bf-blender-cvs] [0fff826] depsgraph_refactor: Depsgraph: Use layers visibility passed from scene_update_for_newframe

Sergey Sharybin noreply at git.blender.org
Wed Dec 31 17:54:23 CET 2014


Commit: 0fff8269c829fdc5b2d642a18c9469ec591269b2
Author: Sergey Sharybin
Date:   Wed Dec 31 21:41:04 2014 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB0fff8269c829fdc5b2d642a18c9469ec591269b2

Depsgraph: Use layers visibility passed from scene_update_for_newframe

This way we can easily deal with the cases when render engine requests for
a different set of layers to be updated without need make bigger changes to
the outside of the dependency graph.

TODO: It is now possible to have some missing scene updates when mixing
update from the viewport and render engine. This isn't difficult to solve
but wouldn't be able to wrap up the patch today.

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

M	source/blender/blenkernel/intern/scene.c
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_tag.cpp

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 84b0102..7c7208b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1797,7 +1797,6 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
 	bool use_new_eval = DEG_get_eval_mode() == DEG_EVAL_MODE_NEW;
 #else
 	/* TODO(sergey): Pass to evaluation routines instead of storing layer in the graph? */
-	(void) lay;
 	(void) do_invisible_flush;
 #endif
 
@@ -1870,7 +1869,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
 		scene_update_tagged_recursive(eval_ctx, bmain, sce, sce);
 	}
 #else
-	DEG_evaluate_on_framechange(eval_ctx, sce->depsgraph, ctime);
+	DEG_evaluate_on_framechange(eval_ctx, sce->depsgraph, ctime, lay);
 #endif
 
 	/* update sound system animation (TODO, move to depsgraph) */
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 7a406f1..f6c513b 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -114,7 +114,9 @@ void DEG_property_tag_update(Depsgraph *graph, const struct PointerRNA *ptr, con
 /* Update Flushing ------------------------------- */
 
 /* Flush updates */
-void DEG_graph_flush_updates(struct EvaluationContext *eval_ctx, Depsgraph *graph);
+void DEG_graph_flush_updates(struct EvaluationContext *eval_ctx,
+                             Depsgraph *graph,
+                             const int layers);
 
 /* Clear all update tags 
  * - For aborted updates, or after successful evaluation
@@ -146,9 +148,18 @@ void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
  */
 void DEG_evaluate_on_framechange(struct EvaluationContext *eval_ctx,
                                  Depsgraph *graph,
-                                 double ctime);
+                                 double ctime,
+                                 const int layer);
 
-/* Data changed recalculation entrypoint 
+/* Data changed recalculation entrypoint.
+ * < context_type: context to perform evaluation for
+ * < layers: visible layers bitmask to update the graph for
+ */
+void DEG_evaluate_on_refresh_ex(struct EvaluationContext *eval_ctx,
+                                Depsgraph *graph,
+                                const int layers);
+
+/* Data changed recalculation entrypoint.
  * < context_type: context to perform evaluation for
  */
 void DEG_evaluate_on_refresh(struct EvaluationContext *eval_ctx,
diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index 773e358..ac7bf60 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -358,13 +358,6 @@ void Depsgraph::add_invisible_entry_tag(OperationDepsNode *node)
 	invisible_entry_tags.insert(node);
 }
 
-/* Get layers for which nodes are to be evaluated. */
-int Depsgraph::layers_for_context(EvaluationContext *eval_ctx)
-{
-	return (eval_ctx->mode == DAG_EVAL_RENDER) ? (1 << 20) - 1
-	                                           : layers;
-}
-
 /* ************************************************** */
 /* Public Graph API */
 
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index add323c..e748910 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -198,9 +198,6 @@ struct Depsgraph {
 	/* Tag a specific invisible node as needing updates when becoming visible. */
 	void add_invisible_entry_tag(OperationDepsNode *node);
 
-	/* Get layers for which nodes are to be evaluated. */
-	int layers_for_context(EvaluationContext *eval_ctx);
-
 	/* Visible layers bitfield, used for skipping invisible objects updates. */
 	int layers;
 
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index c39e3b5..4fd2e32 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -110,12 +110,16 @@ void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
 /* Evaluation Entrypoints */
 
 /* Forward declarations. */
-static void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx,
-                                  Depsgraph *graph, OperationDepsNode *node);
+static void schedule_children(TaskPool *pool,
+                              EvaluationContext *eval_ctx,
+                              Depsgraph *graph,
+                              OperationDepsNode *node,
+                              const int layers);
 
 struct DepsgraphEvalState {
 	EvaluationContext *eval_ctx;
 	Depsgraph *graph;
+	int layers;
 };
 
 static void deg_task_run_func(TaskPool *pool,
@@ -124,31 +128,29 @@ static void deg_task_run_func(TaskPool *pool,
 {
 	DepsgraphEvalState *state = (DepsgraphEvalState *)BLI_task_pool_userdata(pool);
 	OperationDepsNode *node = (OperationDepsNode *)taskdata;
-	if (node->is_noop()) {
-		deg_schedule_children(pool, state->eval_ctx, state->graph, node);
-		return;
-	}
 
-	/* Get context. */
-	// TODO: who initialises this? "Init" operations aren't able to initialise it!!!
-	ComponentDepsNode *comp = node->owner;
-	BLI_assert(comp != NULL);
+	if (!node->is_noop()) {
+		/* Get context. */
+		// TODO: who initialises this? "Init" operations aren't able to initialise it!!!
+		ComponentDepsNode *comp = node->owner;
+		BLI_assert(comp != NULL);
 
-	/* Take note of current time. */
-	double start_time = PIL_check_seconds_timer();
-	DepsgraphDebug::task_started(node);
+		/* Take note of current time. */
+		double start_time = PIL_check_seconds_timer();
+		DepsgraphDebug::task_started(node);
 
-	/* Should only be the case for NOOPs, which never get to this point. */
-	BLI_assert(node->evaluate != NULL);
+		/* Should only be the case for NOOPs, which never get to this point. */
+		BLI_assert(node->evaluate != NULL);
 
-	/* Perform operation. */
-	node->evaluate(state->eval_ctx);
+		/* Perform operation. */
+		node->evaluate(state->eval_ctx);
 
-	/* Note how long this took. */
-	double end_time = PIL_check_seconds_timer();
-	DepsgraphDebug::task_completed(node, end_time - start_time);
+		/* Note how long this took. */
+		double end_time = PIL_check_seconds_timer();
+		DepsgraphDebug::task_completed(node, end_time - start_time);
+	}
 
-	deg_schedule_children(pool, state->eval_ctx, state->graph, node);
+	schedule_children(pool, state->eval_ctx, state->graph, node, state->layers);
 }
 
 static void calculate_pending_parents(Depsgraph *graph)
@@ -211,9 +213,9 @@ static void calculate_eval_priority(OperationDepsNode *node)
 
 static void schedule_graph(TaskPool *pool,
                            EvaluationContext *eval_ctx,
-                           Depsgraph *graph)
+                           Depsgraph *graph,
+                           const int layers)
 {
-	int layers = graph->layers_for_context(eval_ctx);
 	BLI_spin_lock(&graph->lock);
 	for (Depsgraph::OperationNodes::const_iterator it = graph->operations.begin();
 	     it != graph->operations.end();
@@ -232,10 +234,12 @@ static void schedule_graph(TaskPool *pool,
 	BLI_spin_unlock(&graph->lock);
 }
 
-static void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx,
-                                  Depsgraph *graph, OperationDepsNode *node)
+static void schedule_children(TaskPool *pool,
+                              EvaluationContext *eval_ctx,
+                              Depsgraph *graph,
+                              OperationDepsNode *node,
+                              const int layers)
 {
-	int layers = graph->layers_for_context(eval_ctx);
 	for (OperationDepsNode::Relations::const_iterator it = node->outlinks.begin();
 	     it != node->outlinks.end();
 	     ++it)
@@ -270,7 +274,9 @@ static void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx,
  * ! This is usually done as part of main loop, but may also be
  *   called from frame-change update.
  */
-void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
+void DEG_evaluate_on_refresh_ex(EvaluationContext *eval_ctx,
+                                Depsgraph *graph,
+                                const int layers)
 {
 	/* Generate base evaluation context, upon which all the others are derived. */
 	// TODO: this needs both main and scene access...
@@ -279,6 +285,7 @@ void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
 	DepsgraphEvalState state;
 	state.eval_ctx = eval_ctx;
 	state.graph = graph;
+	state.layers = layers;
 
 	TaskScheduler *task_scheduler = BLI_task_scheduler_get();
 	TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &state);
@@ -286,7 +293,7 @@ void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
 	/* Recursively push updates out to all nodes dependent on this,
 	 * until all affected are tagged and/or scheduled up for eval
 	 */
-	DEG_graph_flush_updates(eval_ctx, graph);
+	DEG_graph_flush_updates(eval_ctx, graph, layers);
 
 	calculate_pending_parents(graph);
 
@@ -310,7 +317,7 @@ void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
 
 	DepsgraphDebug::eval_begin(eval_ctx);
 
-	schedule_graph(task_pool, eval_ctx, graph);
+	schedule_graph(task_pool, eval_ctx, graph, layers);
 
 	BLI_task_pool_work_and_wait(task_pool);
 	BLI_task_pool_free(task_pool);
@@ -321,10 +328,18 @@ void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx, Depsgraph *graph)
 	DEG_graph_clear_tags(graph);
 }
 
+/* Evaluate all nodes tagged for updating. */
+void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx,
+                             Depsgraph *graph)
+{
+	DEG_evaluate_on_refresh_ex(eval_ctx, graph, graph->layers);
+}
+
 /* Frame-change happened for root scene that graph belongs to. */
 void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx,
                                  Depsgraph *graph,
-                                 double ctime)
+                                 double ctime,
+                                 const int layers)
 {
 	/* Update time on primary timesource. */
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list