diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-16 00:03:48 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-16 00:07:59 +0400 |
commit | 95acd3b20a494d083ae2a3d5afa25d5bdf310ac8 (patch) | |
tree | 5e8304764035e38e6b71e4dbd00c4728f7318e57 /source/blender/blenkernel/intern/depsgraph.c | |
parent | c78d9a318429703463a74df5ad23722ab37e1bbb (diff) |
Tweak to early threaded update escape
Issue was caused by some objects being in bMain and tagged
for update but not being in the DAG. This means objects
wouldn't be updated and their recalc flag remains untouched
triggering threaded for the next frame.
Solved by tweaking POST_UPDATE_HANDLER_WORKAROUND in the way
that it checks objects' recalc flags from the DAG, not from
the bMain. This will work a bit longer since DAG stored more
nodes than objects in the scene, but this code only runs in
cases when there're some objects tagged for update, which
keeps overall CPU usage on such a workaround pretty low.
Now CPU usage on 11a_comp scene from project Pampa went down
from ~15% down to ~5% (2,69 release uses ~%7).
Pointed by Thomas Dinges in IRC.
Diffstat (limited to 'source/blender/blenkernel/intern/depsgraph.c')
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1c36cccf1e6..b9c9572d599 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2471,7 +2471,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time) #define POST_UPDATE_HANDLER_WORKAROUND -void DAG_ids_clear_recalc(Main *bmain) +void DAG_ids_clear_recalc(Main *bmain, Scene *scene) { ListBase *lbarray[MAX_LIBARRAY]; bNodeTree *ntree; @@ -2479,6 +2479,21 @@ void DAG_ids_clear_recalc(Main *bmain) #ifdef POST_UPDATE_HANDLER_WORKAROUND bool have_updated_objects = false; + + if (DAG_id_type_tagged(bmain, ID_OB)) { + DagNode *node; + for (node = scene->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + Object *object = (Object *) node->ob; + if (object->recalc & OB_RECALC_ALL) { + have_updated_objects = true; + break; + } + } + } + } +#else + (void) scene; /* Unused. */ #endif /* loop over all ID types */ @@ -2495,15 +2510,6 @@ void DAG_ids_clear_recalc(Main *bmain) if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA); -#ifdef POST_UPDATE_HANDLER_WORKAROUND - if (GS(id->name) == ID_OB) { - Object *object = (Object *) id; - if (object->recalc & OB_RECALC_ALL) { - have_updated_objects = true; - } - } -#endif - /* some ID's contain semi-datablock nodetree */ ntree = ntreeFromID(id); if (ntree && (ntree->id.flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA))) |