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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-07-25 17:36:22 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-07-31 17:55:15 +0300
commit3566b81c8bfa8c69d542a5de29ecb8d5af3ccb3d (patch)
tree8c549ae6f2b1064399a7c0b99ab6ce9b287bdd28 /source/blender/editors/render
parentf5f3003874f26681000618032d88482367348064 (diff)
Refactor access to dependency graph
This change ensures that operators which needs access to evaluated data first makes sure there is a dependency graph. Other accesses to the dependency graph made it more explicit about whether they just need a valid dependency graph pointer or whether they expect the graph to be already evaluated. This replaces OPTYPE_USE_EVAL_DATA which is now removed. Some general rules about usage of accessors: - Drawing is expected to happen from a fully evaluated dependency graph. There is now a function to access it, which will in the future control that dependency graph is actually evaluated. This check is not yet done because there are some things to be taken care about first: for example, post-update hooks might leave scene in a state where something is still tagged for update. - All operators which needs to access evaluated state must use CTX_data_ensure_evaluated_depsgraph(). This function replaces OPTYPE_USE_EVAL_DATA. The call is generally to be done in the very beginning of the operator, prior other logic (unless this is some comprehensive operator which might or might not need access to an evaluated state). This call is never to be used from a loop. If some utility function requires evaluated state of dependency graph the graph is to be passed as an explicit argument. This way it is clear that no evaluation happens in a loop or something like this. - All cases which needs to know dependency graph pointer, but which doesn't want to actually evaluate it can use old-style function CTX_data_depsgraph_pointer(), assuming that underlying code will ensure dependency graph is evaluated prior to accessing it. - The new functions are replacing OPTYPE_USE_EVAL_DATA, so now it is explicit and local about where dependency graph is being ensured. This commit also contains some fixes of wrong usage of evaluation functions on original objects. Ideally should be split out, but in reality with all the APIs being renamed is quite tricky. Fixes T67454: Blender crash on rapid undo and select Speculation here is that sometimes undo and selection operators are sometimes handled in the same event loop iteration, which leaves non-evaluated dependency graph. Fixes T67973: Crash on Fix Deforms operator Fixes T67902: Crash when undo a loop cut Reviewers: brecht Reviewed By: brecht Subscribers: lichtwerk Maniphest Tasks: T67454 Differential Revision: https://developer.blender.org/D5343
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_internal.c9
-rw-r--r--source/blender/editors/render/render_opengl.c6
-rw-r--r--source/blender/editors/render/render_shading.c2
-rw-r--r--source/blender/editors/render/render_update.c2
4 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 9ac93f07300..acd7126e56a 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -368,7 +368,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_SetReports(re, NULL);
// no redraw needed, we leave state as we entered it
- ED_update_for_newframe(mainp, CTX_data_depsgraph(C));
+ ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
@@ -978,8 +978,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->scene = scene;
rj->current_scene = rj->scene;
rj->single_layer = single_layer;
- /* TODO(sergey): Render engine should be using own depsgraph. */
- rj->depsgraph = CTX_data_depsgraph(C);
+ /* TODO(sergey): Render engine should be using own depsgraph.
+ *
+ * NOTE: Currently is only used by ED_update_for_newframe() at the end of the render, so no
+ * need to ensure evaluation here. */
+ rj->depsgraph = CTX_data_depsgraph_pointer(C);
rj->camera_override = camera_override;
rj->anim = is_animation;
rj->write_still = is_write_still && !is_animation;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 72e6c6fdf03..f419d30a17e 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -273,7 +273,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = oglrender->scene;
ARegion *ar = oglrender->ar;
View3D *v3d = oglrender->v3d;
@@ -592,7 +592,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->scene = scene;
oglrender->workspace = workspace;
oglrender->view_layer = CTX_data_view_layer(C);
- oglrender->depsgraph = CTX_data_depsgraph(C);
+ /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize
+ * output video handles, which does need evaluated scene. */
+ oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
oglrender->cfrao = scene->r.cfra;
oglrender->ofs_samples = samples;
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index f7a1d7187f1..5c305f45fb2 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -859,7 +859,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op)
EEVEE_lightbake_job_data_free(rj);
// no redraw needed, we leave state as we entered it
- ED_update_for_newframe(bmain, CTX_data_depsgraph(C));
+ ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 64869b71746..82e4d577777 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -135,7 +135,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
/* NOTE: Important to pass non-updated depsgraph, This is because this function is called
* from inside dependency graph evaluation. Additionally, if we pass fully evaluated one
* we will loose updates stored in the graph. */
- engine->type->view_update(engine, C, CTX_data_depsgraph(C));
+ engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C));
}
else {
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);