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/editors/space_view3d | |
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/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 4 |
3 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f825f7ecf9f..9eb3fb320be 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -59,6 +59,7 @@ #include "BKE_image.h" #include "BKE_key.h" #include "BKE_lattice.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_material.h" #include "BKE_mball.h" @@ -4056,7 +4057,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3 if (BKE_mball_is_basis(ob)) { lb = ob->curve_cache ? &ob->curve_cache->disp : NULL; if (ELEM(NULL, lb, lb->first)) { - BKE_displist_make_mball(scene, ob); + BKE_displist_make_mball(G.main->eval_ctx, scene, ob); lb = &ob->curve_cache->disp; } if (lb->first == NULL) { @@ -6268,7 +6269,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { - BKE_displist_make_mball(scene, ob); + BKE_displist_make_mball(G.main->eval_ctx, scene, ob); bb = ob->bb; } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 701fb26a562..f0a943d593e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -55,6 +55,7 @@ #include "BKE_customdata.h" #include "BKE_image.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_global.h" #include "BKE_paint.h" @@ -1968,7 +1969,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas if (base->object->restrictflag & OB_RESTRICT_VIEW) return; tbase.flag = OB_FROMDUPLI | base->flag; - lb = object_duplilist(scene, base->object, false); + lb = object_duplilist(G.main->eval_ctx, scene, base->object); // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ dob = dupli_step(lb->first); @@ -2402,7 +2403,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) if (ob->transflag & OB_DUPLI) { DupliObject *dob; - ListBase *lb = object_duplilist(scene, ob, false); + ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob); for (dob = lb->first; dob; dob = dob->next) if (dob->ob->type == OB_LAMP) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d81ab0319e6..dcbcb127f5c 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -984,7 +984,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b Base tbase; tbase.flag = OB_FROMDUPLI; - lb = object_duplilist(scene, base->object, false); + lb = object_duplilist(G.main->eval_ctx, scene, base->object); for (dob = lb->first; dob; dob = dob->next) { tbase.object = dob->ob; @@ -1543,7 +1543,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) //XXX restore_all_scene_cfra(scene_cfra_store); BKE_scene_set_background(CTX_data_main(C), startscene); - //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); + //XXX BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay); BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_POST); |