Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-06 13:07:27 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-16 20:55:33 +0300
commit34ab90f546f097cada951b2c9ca22bf271996980 (patch)
treeebcdb3d37120ac1d8fb16462b9104badd1800329 /source/blender/depsgraph
parent0c495005dd83913864acb510c1d4194a2275dbb0 (diff)
Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing both risks the depsgraph and evaluation context not matching, and it complicates the Python API where we'd have to expose both which is not so easy to understand. This also removes the global evaluation context in main, which assumed there to be a single active scene and view layer. Differential Revision: https://developer.blender.org/D3152
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h45
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h1
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h1
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_eval.cc70
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc13
-rw-r--r--source/blender/depsgraph/intern/depsgraph_types.h4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc18
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h6
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h2
12 files changed, 21 insertions, 147 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 4760c88cdbd..b30c99cbc0e 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -60,7 +60,6 @@ typedef struct Depsgraph Depsgraph;
/* ------------------------------------------------ */
-struct EvaluationContext;
struct Main;
struct PointerRNA;
@@ -75,19 +74,6 @@ typedef enum eEvaluationMode {
DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
} eEvaluationMode;
-/* Dependency graph evaluation context
- *
- * This structure stores all the local dependency graph data,
- * which is needed for it's evaluation,
- */
-typedef struct EvaluationContext {
- eEvaluationMode mode;
- float ctime;
-
- struct Depsgraph *depsgraph;
- struct ViewLayer *view_layer;
-} EvaluationContext;
-
/* DagNode->eval_flags */
enum {
/* Regardless to curve->path animation flag path is to be evaluated anyway,
@@ -203,37 +189,6 @@ void DEG_ids_check_recalc(struct Main *bmain,
/* ************************************************ */
/* Evaluation Engine API */
-/* Evaluation Context ---------------------------- */
-
-/* Create new evaluation context. */
-struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
-
-/* Initialize evaluation context.
- * Used by the areas which currently overrides the context or doesn't have
- * access to a proper one.
- */
-void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
- eEvaluationMode mode);
-void DEG_evaluation_context_init_from_scene(
- struct EvaluationContext *eval_ctx,
- struct Scene *scene,
- struct ViewLayer *view_layer,
- eEvaluationMode mode);
-
-void DEG_evaluation_context_init_from_view_layer_for_render(
- struct EvaluationContext *eval_ctx,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct ViewLayer *view_layer);
-
-void DEG_evaluation_context_init_from_depsgraph(
- struct EvaluationContext *eval_ctx,
- struct Depsgraph *depsgraph,
- eEvaluationMode mode);
-
-/* Free evaluation context. */
-void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
-
/* Graph Evaluation ----------------------------- */
/* Frame changed recalculation entry point
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 334b15cc638..3460cbf7c91 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -42,7 +42,6 @@ struct Depsgraph;
struct CacheFile;
struct EffectorWeights;
-struct EvaluationContext;
struct Group;
struct Main;
struct ModifierData;
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index ceba87338a0..902a2ea3981 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -106,7 +106,6 @@ typedef struct DEGObjectIterData {
int flag;
struct Scene *scene;
- struct EvaluationContext eval_ctx;
int visibility_check; /* eObjectVisibilityCheck. */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 92af811dab4..ca31c1c15a1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -170,7 +170,7 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
ComponentDepsNode *comp_cow =
id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE);
OperationDepsNode *op_cow = comp_cow->add_operation(
- function_bind(deg_evaluate_copy_on_write, _1, graph_, id_node),
+ function_bind(deg_evaluate_copy_on_write, _1, id_node),
DEG_OPCODE_COPY_ON_WRITE,
"", -1);
graph_->operations.push_back(op_cow);
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index ac92d440bbe..edb6600f3e0 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -55,76 +55,6 @@ extern "C" {
#include "intern/depsgraph.h"
-/* ****************** */
-/* Evaluation Context */
-
-/* Create new evaluation context. */
-EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode)
-{
- EvaluationContext *eval_ctx =
- (EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
- "EvaluationContext");
- DEG_evaluation_context_init(eval_ctx, mode);
- return eval_ctx;
-}
-
-/**
- * Initialize evaluation context.
- * Used by the areas which currently overrides the context or doesn't have
- * access to a proper one.
- */
-void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
- eEvaluationMode mode)
-{
- eval_ctx->mode = mode;
-}
-
-void DEG_evaluation_context_init_from_scene(
- EvaluationContext *eval_ctx,
- Scene *scene,
- ViewLayer *view_layer,
- eEvaluationMode mode)
-{
- DEG_evaluation_context_init(eval_ctx, mode);
- eval_ctx->depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
- eval_ctx->view_layer = view_layer;
- eval_ctx->ctime = BKE_scene_frame_get(scene);
-}
-
-void DEG_evaluation_context_init_from_view_layer_for_render(
- EvaluationContext *eval_ctx,
- Depsgraph *depsgraph,
- Scene *scene,
- ViewLayer *view_layer)
-{
- /* ViewLayer may come from a copy of scene.viewlayers, we need to find the original though. */
- ViewLayer *view_layer_original = (ViewLayer *)BLI_findstring(&scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
- BLI_assert(view_layer_original != NULL);
-
- DEG_evaluation_context_init(eval_ctx, DAG_EVAL_RENDER);
- eval_ctx->ctime = BKE_scene_frame_get(scene);
- eval_ctx->depsgraph = depsgraph;
- eval_ctx->view_layer = view_layer_original;
-}
-
-void DEG_evaluation_context_init_from_depsgraph(
- EvaluationContext *eval_ctx,
- Depsgraph *depsgraph,
- eEvaluationMode mode)
-{
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
- DEG_evaluation_context_init(eval_ctx, mode);
- eval_ctx->ctime = (float)scene->r.cfra + scene->r.subframe;
- eval_ctx->depsgraph = depsgraph;
- eval_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph);
-}
-
-/* Free evaluation context. */
-void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
-{
- MEM_freeN(eval_ctx);
-}
-
/* Evaluate all nodes tagged for updating. */
void DEG_evaluate_on_refresh(Depsgraph *graph)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 61f1ccdd2a0..c610e7fc500 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -187,7 +187,7 @@ static void DEG_iterator_objects_step(BLI_Iterator *iter, DEG::IDDepsNode *id_no
(object->transflag & OB_DUPLI))
{
data->dupli_parent = object;
- data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, object);
+ data->dupli_list = object_duplilist(data->graph, data->scene, object);
data->dupli_object_next = (DupliObject *)data->dupli_list->first;
if (BKE_object_is_visible(object, (eObjectVisibilityCheck)data->visibility_check) == false) {
return;
@@ -209,13 +209,10 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
return;
}
- /* TODO(sergey): What evaluation type we want here? */
- /* TODO(dfelinto): Get rid of evaluation context here, it's only used to do
- * direct dupli-objects update in group.c. Which is terribly bad, and all
- * objects are expected to be evaluated already. */
- DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_VIEWPORT);
- data->eval_ctx.depsgraph = depsgraph;
- data->eval_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ /* TODO: Calling this forces the scene datablock to be expanded,
+ * otherwise we get crashes on load with copy-on-write. There may
+ * be a better solution for this. */
+ DEG_get_evaluated_view_layer(depsgraph);
iter->data = data;
data->dupli_parent = NULL;
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index d6c410347f6..6d328b399e0 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -49,8 +49,8 @@ struct bAction;
struct ChannelDriver;
struct ModifierData;
struct PointerRNA;
-struct EvaluationContext;
struct FCurve;
+struct Depsgraph;
namespace DEG {
@@ -61,7 +61,7 @@ using std::max;
/* Evaluation Operation for atomic operation */
// XXX: move this to another header that can be exposed?
-typedef function<void(struct EvaluationContext *)> DepsEvalOperationCb;
+typedef function<void(struct ::Depsgraph *)> DepsEvalOperationCb;
/* Metatype of Nodes - The general "level" in the graph structure
* the node serves.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index d40e3e85979..4dd3842070e 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -69,7 +69,6 @@ static void schedule_children(TaskPool *pool,
const int thread_id);
struct DepsgraphEvalState {
- EvaluationContext *eval_ctx;
Depsgraph *graph;
bool do_stats;
};
@@ -86,11 +85,11 @@ static void deg_task_run_func(TaskPool *pool,
/* Perform operation. */
if (state->do_stats) {
const double start_time = PIL_check_seconds_timer();
- node->evaluate(state->eval_ctx);
+ node->evaluate((::Depsgraph*)state->graph);
node->stats.current_time += PIL_check_seconds_timer() - start_time;
}
else {
- node->evaluate(state->eval_ctx);
+ node->evaluate((::Depsgraph*)state->graph);
}
/* Schedule children. */
BLI_task_pool_delayed_push_begin(pool, thread_id);
@@ -229,21 +228,20 @@ static void schedule_children(TaskPool *pool,
*/
void deg_evaluate_on_refresh(Depsgraph *graph)
{
- /* Set time for the current graph evaluation context. */
- TimeSourceDepsNode *time_src = graph->find_time_source();
/* Nothing to update, early out. */
if (BLI_gset_len(graph->entry_tags) == 0) {
return;
}
const bool do_time_debug = ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
const double start_time = do_time_debug ? PIL_check_seconds_timer() : 0;
- /* Set up evaluation context. */
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init_from_depsgraph(&eval_ctx, (::Depsgraph*)graph, graph->mode);
- eval_ctx.ctime = time_src->cfra;
+
+ /* TODO: Calling this forces the scene datablock to be expanded,
+ * otherwise we get crashes on load with copy-on-write. There may
+ * be a better solution for this. */
+ DEG_get_evaluated_view_layer((const ::Depsgraph*)graph);
+
/* Set up evaluation state. */
DepsgraphEvalState state;
- state.eval_ctx = &eval_ctx;
state.graph = graph;
state.do_stats = do_time_debug;
/* Set up task scheduler and pull for threaded evaluation. */
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.h b/source/blender/depsgraph/intern/eval/deg_eval.h
index 0fb60e8f779..a8f5f7c145f 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval.h
@@ -32,8 +32,6 @@
#pragma once
-struct EvaluationContext;
-
namespace DEG {
struct Depsgraph;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 1d2169f5ec4..91790522590 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -781,10 +781,10 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
id_cow->name[0] = '\0';
}
-void deg_evaluate_copy_on_write(const EvaluationContext * /*eval_ctx*/,
- const Depsgraph *depsgraph,
+void deg_evaluate_copy_on_write(struct ::Depsgraph *graph,
const IDDepsNode *id_node)
{
+ const DEG::Depsgraph *depsgraph = reinterpret_cast<const DEG::Depsgraph *>(graph);
DEBUG_PRINT("%s on %s\n", __func__, id_node->id_orig->name);
if (id_node->id_orig == &depsgraph->scene->id) {
/* NOTE: This is handled by eval_ctx setup routines, which
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index a2b57cb7198..8fca90e9f5b 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -32,7 +32,6 @@
#include <stddef.h>
-struct EvaluationContext;
struct ID;
/* Unkomment this to have verbose log about original and CoW pointers
@@ -47,6 +46,8 @@ struct ID;
# define DEG_COW_PRINT(format, ...)
#endif
+struct Depsgraph;
+
namespace DEG {
struct Depsgraph;
@@ -79,8 +80,7 @@ void deg_free_copy_on_write_datablock(struct ID *id_cow);
/* Callback function for depsgraph operation node which ensures copy-on-write
* datablock is ready for use by further evaluation routines.
*/
-void deg_evaluate_copy_on_write(const struct EvaluationContext *eval_ctx,
- const struct Depsgraph *depsgraph,
+void deg_evaluate_copy_on_write(struct ::Depsgraph *depsgraph,
const struct IDDepsNode *id_node);
/* Check that given ID is propely expanded and does not have any shallow
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index b8009cc0a7f..5b6461f950e 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -39,8 +39,6 @@ struct ID;
struct bPoseChannel;
struct GHash;
-struct EvaluationContext;
-
namespace DEG {
struct Depsgraph;