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.
This commit is contained in:
@@ -128,7 +128,7 @@ int DAG_id_type_tagged(struct Main *bmain, short idtype);
|
||||
void DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time);
|
||||
void DAG_ids_flush_tagged(struct Main *bmain);
|
||||
void DAG_ids_check_recalc(struct Main *bmain, struct Scene *scene, int time);
|
||||
void DAG_ids_clear_recalc(struct Main *bmain);
|
||||
void DAG_ids_clear_recalc(struct Main *bmain, struct Scene *scene);
|
||||
|
||||
/* Armature: sorts the bones according to dependencies between them */
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -1563,7 +1563,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
|
||||
DAG_ids_check_recalc(bmain, scene, FALSE);
|
||||
|
||||
/* clear recalc flags */
|
||||
DAG_ids_clear_recalc(bmain);
|
||||
DAG_ids_clear_recalc(bmain, scene);
|
||||
}
|
||||
|
||||
/* applies changes right away, does all sets too */
|
||||
@@ -1639,7 +1639,7 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
|
||||
DAG_ids_check_recalc(bmain, sce, TRUE);
|
||||
|
||||
/* clear recalc flags */
|
||||
DAG_ids_clear_recalc(bmain);
|
||||
DAG_ids_clear_recalc(bmain, sce);
|
||||
|
||||
#ifdef DETAILED_ANALYSIS_OUTPUT
|
||||
fprintf(stderr, "frame update start_time %f duration %f\n", start_time, PIL_check_seconds_timer() - start_time);
|
||||
|
||||
Reference in New Issue
Block a user