diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-15 11:43:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-15 11:43:18 +0300 |
commit | c4046e9082f61bfef87173d20c566a065f2602d7 (patch) | |
tree | d04eb7411cb107ed05c3e6e9a83a54065b4a46a4 | |
parent | 400d59be9b058d4bfa31a84547591275f7c700b9 (diff) |
Move ID recalc flags into dedicated field in ID
Currently this is a no-visible-changes change, but the idea is to use this
dedicated flag to tell which exact components of ID changed, make it more
granular than just OBJECT and OBJECT_DATA. Allow setting this field based
on what components new dependency graph flushed on evaluation.
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder.cc | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_tag.cc | 12 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_flush.cc | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_ID.h | 20 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_correctivesmooth.c | 2 |
13 files changed, 45 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 6107bb1e32e..ba8f454aa47 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -74,6 +74,8 @@ #include "nla_private.h" +#include "atomic_ops.h" + /* ***************************************** */ /* AnimData API */ @@ -1663,8 +1665,11 @@ static bool animsys_write_rna_setting(PathResolvedRNA *anim_rna, const float val /* for cases like duplifarmes it's only a temporary so don't * notify anyone of updates */ - if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) { - BKE_id_tag_set_atomic(id, LIB_TAG_ID_RECALC); + if (!(id->recalc & ID_RECALC_SKIP_ANIM_TAG)) { + /* NOTE: This is a bit annoying to use atomic API here, but this + * code is at it's EOL and removed already in 2.8 branch. + */ + atomic_fetch_and_or_int32(&id->recalc, ID_RECALC); DAG_id_type_tag(G.main, GS(id->name)); } } @@ -2618,8 +2623,8 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData */ if (ptr->id.data != NULL) { ID *id = ptr->id.data; - if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) { - id->tag |= LIB_TAG_ID_RECALC; + if (!(id->recalc & ID_RECALC_SKIP_ANIM_TAG)) { + id->recalc |= ID_RECALC; DAG_id_type_tag(G.main, GS(id->name)); } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index e9b83b27ef2..81e88bd3019 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1532,7 +1532,7 @@ static bool check_object_tagged_for_update(Object *object) if (ELEM(object->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) { ID *data_id = object->data; - return (data_id->tag & LIB_TAG_ID_RECALC_ALL) != 0; + return (data_id->recalc & ID_RECALC_ALL) != 0; } return false; @@ -1780,13 +1780,13 @@ void DAG_scene_free(Scene *sce) static void lib_id_recalc_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC; + id->recalc |= ID_RECALC; DAG_id_type_tag(bmain, GS(id->name)); } static void lib_id_recalc_data_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC_DATA; + id->recalc |= ID_RECALC_DATA; DAG_id_type_tag(bmain, GS(id->name)); } @@ -2825,7 +2825,7 @@ void DAG_ids_flush_tagged(Main *bmain) if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) { for (; id; id = id->next) { - if (id->tag & LIB_TAG_ID_RECALC_ALL) { + if (id->recalc & ID_RECALC_ALL) { for (dsl = listbase.first; dsl; dsl = dsl->next) dag_id_flush_update(bmain, dsl->scene, id); @@ -2945,12 +2945,12 @@ void DAG_ids_clear_recalc(Main *bmain) if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) { for (; id; id = id->next) { - id->tag &= ~LIB_TAG_ID_RECALC_ALL; + id->recalc &= ~ID_RECALC_ALL; /* some ID's contain semi-datablock nodetree */ ntree = ntreeFromID(id); if (ntree) - ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL; + ntree->id.recalc &= ~ID_RECALC_ALL; } } } diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index cd697cadc0e..ff4e7f36018 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1463,8 +1463,8 @@ void BKE_mask_update_scene(Main *bmain, Scene *scene) Mask *mask; for (mask = bmain->mask.first; mask; mask = mask->id.next) { - if (mask->id.tag & LIB_TAG_ID_RECALC_ALL) { - bool do_new_frame = (mask->id.tag & LIB_TAG_ID_RECALC_DATA) != 0; + if (mask->id.recalc & ID_RECALC_ALL) { + bool do_new_frame = (mask->id.recalc & ID_RECALC_DATA) != 0; BKE_mask_evaluate_all_masks(bmain, CFRA, do_new_frame); } } diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index b49e481b068..93bc79095d7 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -379,7 +379,7 @@ static void make_duplis_frames(const DupliContext *ctx) /* special flag to avoid setting recalc flags to notify the depsgraph of * updates, as this is not a permanent change to the object */ - ob->id.tag |= LIB_TAG_ANIM_NO_RECALC; + ob->id.recalc |= ID_RECALC_SKIP_ANIM_TAG; for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) { int ok = 1; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9ce578a9105..e45d2887250 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1841,8 +1841,8 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene) if (obedit) { Mesh *mesh = obedit->data; if ((obedit->type == OB_MESH) && - ((obedit->id.tag & LIB_TAG_ID_RECALC_ALL) || - (mesh->id.tag & LIB_TAG_ID_RECALC_ALL))) + ((obedit->id.recalc & ID_RECALC_ALL) || + (mesh->id.recalc & ID_RECALC_ALL))) { if (check_rendered_viewport_visible(bmain)) { BMesh *bm = mesh->edit_btmesh->bm; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b6543fc8662..f43eecffe60 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3077,7 +3077,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) ntree->adt = newdataadr(fd, ntree->adt); direct_link_animdata(fd, ntree->adt); - ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL; + ntree->id.recalc &= ~ID_RECALC_ALL; link_list(fd, &ntree->nodes); for (node = ntree->nodes.first; node; node = node->next) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index e3494e4756e..26f729a16d7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -153,7 +153,7 @@ void deg_graph_build_finalize(Depsgraph *graph) if ((id_node->layers & graph->layers) != 0 || graph->layers == 0) { ID *id = id_node->id; - if ((id->tag & LIB_TAG_ID_RECALC_ALL) && + if ((id->recalc & ID_RECALC_ALL) && (id->tag & LIB_TAG_DOIT)) { id_node->tag_update(graph); diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 7e9b2f5c58c..dd7284eb629 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -312,7 +312,7 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, if (comp_node->type == DEG_NODE_TYPE_GEOMETRY) { IDDepsNode *id_to = to->owner->owner; IDDepsNode *id_from = from->owner->owner; - if (id_to != id_from && (id_to->id->tag & LIB_TAG_ID_RECALC_ALL)) { + if (id_to != id_from && (id_to->id->recalc & ID_RECALC_ALL)) { if ((id_from->eval_flags & DAG_EVAL_NEED_CPU) == 0) { id_from->tag_update(this); id_from->eval_flags |= DAG_EVAL_NEED_CPU; diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 8f91a826760..79c30e7904d 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -83,13 +83,13 @@ namespace { void lib_id_recalc_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC; + id->recalc |= ID_RECALC; DEG_id_type_tag(bmain, GS(id->name)); } void lib_id_recalc_data_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC_DATA; + id->recalc |= ID_RECALC_DATA; DEG_id_type_tag(bmain, GS(id->name)); } @@ -295,7 +295,7 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene) GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash) { ID *id = id_node->id; - if ((id->tag & LIB_TAG_ID_RECALC_ALL) != 0 || + if ((id->recalc & ID_RECALC_ALL) != 0 || (id_node->layers & scene->lay_updated) == 0) { id_node->tag_update(graph); @@ -307,7 +307,7 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene) */ if (GS(id->name) == ID_OB) { Object *object = (Object *)id; - if ((id->tag & LIB_TAG_ID_RECALC_ALL) == 0 && + if ((id->recalc & ID_RECALC_ALL) == 0 && (object->recalc & OB_RECALC_ALL) != 0) { id_node->tag_update(graph); @@ -409,12 +409,12 @@ void DEG_ids_clear_recalc(Main *bmain) if (id && bmain->id_tag_update[BKE_idcode_to_index(GS(id->name))]) { for (; id; id = (ID *)id->next) { - id->tag &= ~LIB_TAG_ID_RECALC_ALL; + id->recalc &= ~ID_RECALC_ALL; /* Some ID's contain semi-datablock nodetree */ ntree = ntreeFromID(id); if (ntree != NULL) { - ntree->id.tag &= ~LIB_TAG_ID_RECALC_ALL; + ntree->id.recalc &= ~ID_RECALC_ALL; } } } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index dcd9a17761d..107bbda1030 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -65,13 +65,13 @@ namespace { // TODO(sergey): De-duplicate with depsgraph_tag,cc void lib_id_recalc_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC; + id->recalc |= ID_RECALC; DEG_id_type_tag(bmain, GS(id->name)); } void lib_id_recalc_data_tag(Main *bmain, ID *id) { - id->tag |= LIB_TAG_ID_RECALC_DATA; + id->recalc |= ID_RECALC_DATA; DEG_id_type_tag(bmain, GS(id->name)); } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index f0fc651353f..c1c4d6c5376 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -348,18 +348,20 @@ enum { /* RESET_AFTER_USE tag existing data before linking so we know what is new. */ LIB_TAG_PRE_EXISTING = 1 << 11, - /* RESET_AFTER_USE, used by update code (depsgraph). */ - LIB_TAG_ID_RECALC = 1 << 12, - LIB_TAG_ID_RECALC_DATA = 1 << 13, - LIB_TAG_ANIM_NO_RECALC = 1 << 14, - LIB_TAG_ID_RECALC_ALL = (LIB_TAG_ID_RECALC | LIB_TAG_ID_RECALC_DATA), - /* RESET_NEVER tag datablock for freeing etc. behavior (usually set when copying real one into temp/runtime one). */ - LIB_TAG_NO_MAIN = 1 << 16, /* Datablock is not listed in Main database. */ - LIB_TAG_NO_USER_REFCOUNT = 1 << 17, /* Datablock does not refcount usages of other IDs. */ + LIB_TAG_NO_MAIN = 1 << 11, /* Datablock is not listed in Main database. */ + LIB_TAG_NO_USER_REFCOUNT = 1 << 13, /* Datablock does not refcount usages of other IDs. */ /* Datablock was not allocated by standard system (BKE_libblock_alloc), do not free its memory * (usual type-specific freeing is called though). */ - LIB_TAG_NOT_ALLOCATED = 1 << 18, + LIB_TAG_NOT_ALLOCATED = 1 << 14, +}; + +enum { + /* RESET_AFTER_USE, used by update code (depsgraph). */ + ID_RECALC = 1 << 0, + ID_RECALC_DATA = 1 << 1, + ID_RECALC_SKIP_ANIM_TAG = 1 << 2, + ID_RECALC_ALL = (ID_RECALC | ID_RECALC_DATA), }; /* To filter ID types (filter_id) */ diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 9205e15671b..a9e34247cbd 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -997,12 +997,12 @@ static void rna_def_ID(BlenderRNA *brna) "(initial state is undefined)"); prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_ID_RECALC); + RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Is Updated", "Data-block is tagged for recalculation"); prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_ID_RECALC_DATA); + RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC_DATA); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Is Updated Data", "Data-block data is tagged for recalculation"); diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 77fd84a2948..1c3a5d3d7be 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -575,7 +575,7 @@ static void correctivesmooth_modifier_do( const bool force_delta_cache_update = /* XXX, take care! if mesh data its self changes we need to forcefully recalculate deltas */ ((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_ORCO) && - (((ID *)ob->data)->tag & LIB_TAG_ID_RECALC)); + (((ID *)ob->data)->recalc & ID_RECALC)); bool use_only_smooth = (csmd->flag & MOD_CORRECTIVESMOOTH_ONLY_SMOOTH) != 0; MDeformVert *dvert = NULL; |