diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-12-26 15:24:42 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-12-26 15:24:42 +0400 |
commit | 709041ed0b7e1848068c9d53543ed114229a9f5b (patch) | |
tree | edf2cd930e6bcfd9bbc9ab7fd21490effb069e09 /source/blender/blenkernel/intern/sequencer.c | |
parent | 7025a1bd7830c3bb58ea7f6a3dba8089869591eb (diff) |
Threaded object update and EvaluationContext
Summary:
Made objects update happening from multiple threads. It is a task-based
scheduling system which uses current dependency graph for spawning new
tasks. This means threading happens on object level, but the system is
flexible enough for higher granularity.
Technical details:
- Uses task scheduler which was recently committed to trunk
(that one which Brecht ported from Cycles).
- Added two utility functions to dependency graph:
* DAG_threaded_update_begin, which is called to initialize threaded
objects update. It will also schedule root DAG node to the queue,
hence starting evaluation process.
Initialization will calculate how much parents are to be evaluation
before current DAG node can be scheduled. This value is used by task
threads for faster detecting which nodes might be scheduled.
* DAG_threaded_update_handle_node_updated which is called from task
thread function when node was fully handled.
This function decreases num_pending_parents of node children and
schedules children with zero valency.
As it might have become clear, task thread receives DAG nodes and
decides which callback to call for it.
Currently only BKE_object_handle_update is called for object nodes.
In the future it'll call node->callback() from Ali's new DAG.
- This required adding some workarounds to the render pipeline.
Mainly to stop using get_object_dm() from modifiers' apply callback.
Such a call was only a workaround for dependency graph glitch when
rendering scene with, say, boolean modifiers before displaying
this scene.
Such change moves workaround from one place to another, so overall
hackentropy remains the same.
- Added paradigm of EvaluaitonContext. Currently it's more like just a
more reliable replacement for G.is_rendering which fails in some
circumstances.
Future idea of this context is to also store all the local data needed
for objects evaluation such as local time, Copy-on-Write data and so.
There're two types of EvaluationContext:
* Context used for viewport updated and owned by Main. In the future
this context might be easily moved to Window or Screen to allo
per-window/per-screen local time.
* Context used by render engines to evaluate objects for render purposes.
Render engine is an owner of this context.
This context is passed to all object update routines.
Reviewers: brecht, campbellbarton
Reviewed By: brecht
CC: lukastoenne
Differential Revision: https://developer.blender.org/D94
Diffstat (limited to 'source/blender/blenkernel/intern/sequencer.c')
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 49b237fc3ea..dd2bd4383b6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -57,6 +57,7 @@ #include "BLF_translation.h" #include "BKE_animsys.h" +#include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" @@ -498,7 +499,9 @@ void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixe /*********************** sequencer pipeline functions *************************/ -SeqRenderData BKE_sequencer_new_render_data(Main *bmain, Scene *scene, int rectx, int recty, int preview_render_size) +SeqRenderData BKE_sequencer_new_render_data(EvaluationContext *eval_ctx, + Main *bmain, Scene *scene, int rectx, int recty, + int preview_render_size) { SeqRenderData rval; @@ -509,6 +512,7 @@ SeqRenderData BKE_sequencer_new_render_data(Main *bmain, Scene *scene, int rectx rval.preview_render_size = preview_render_size; rval.motion_blur_samples = 0; rval.motion_blur_shutter = 0; + rval.eval_ctx = eval_ctx; return rval; } @@ -1506,6 +1510,7 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context, short *stop, sho SeqRenderData render_context; Sequence *seq = context->seq; Scene *scene = context->scene; + Main *bmain = context->bmain; int cfra; if (seq->type == SEQ_TYPE_MOVIE) { @@ -1527,7 +1532,7 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context, short *stop, sho /* fail safe code */ - render_context = BKE_sequencer_new_render_data(context->bmain, context->scene, + render_context = BKE_sequencer_new_render_data(bmain->eval_ctx, bmain, context->scene, (scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f, (scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f, 100); @@ -2449,7 +2454,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float const short is_rendering = G.is_rendering; const short is_background = G.background; - const int do_seq_gl = G.is_rendering ? + const int do_seq_gl = is_rendering ? 0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ : (context.scene->r.seq_flag & R_SEQ_GL_PREV); int do_seq; @@ -2505,7 +2510,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float context.scene->r.seq_prev_type = 3 /* == OB_SOLID */; /* opengl offscreen render */ - BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); + BKE_scene_update_for_newframe(context.eval_ctx, context.bmain, scene, scene->lay); ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, context.scene->r.seq_flag & R_SEQ_SOLID_TEX, TRUE, scene->r.alphamode, err_out); @@ -2528,8 +2533,8 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float if (!is_thread_main || is_rendering == FALSE || is_background) { if (re == NULL) re = RE_NewRender(scene->id.name); - - BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); + + BKE_scene_update_for_newframe(context.eval_ctx, context.bmain, scene, scene->lay); RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ @@ -2564,8 +2569,9 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float scene->r.cfra = oldcfra; - if (frame != oldcfra) - BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); + if (frame != oldcfra) { + BKE_scene_update_for_newframe(context.eval_ctx, context.bmain, scene, scene->lay); + } #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ |