diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-08 16:48:25 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-08 17:02:19 +0300 |
commit | 19c14f0c8ac6236eedff2a1c5f3581b4fca79bf1 (patch) | |
tree | 2625e4af3ed7e2972e92e39ddfded477d9d546de /source | |
parent | 10f076da2d687a77a317e060bf69d95fb49ad075 (diff) |
Subject: [PATCH 2/3] Depsgraph: Replace iteration over ghash with iteration over flat array
Diffstat (limited to 'source')
7 files changed, 11 insertions, 31 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 4755e7d211d..d6a054f2ee9 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -30,17 +30,15 @@ #include "intern/builder/deg_builder.h" -#include "DNA_anim_types.h" #include "DNA_object_types.h" #include "DNA_ID.h" -#include "BLI_utildefines.h" -#include "BLI_ghash.h" - #include "intern/depsgraph.h" #include "intern/depsgraph_types.h" #include "intern/nodes/deg_node.h" +#include "util/deg_util_foreach.h" + #include "DEG_depsgraph.h" namespace DEG { @@ -51,8 +49,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) /* Re-tag IDs for update if it was tagged before the relations * update tag. */ - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash) - { + foreach (IDDepsNode *id_node, graph->id_nodes) { ID *id = id_node->id_orig; id_node->finalize_build(graph); if ((id->tag & LIB_TAG_ID_RECALC_ALL)) { @@ -71,7 +68,6 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) DEG_id_tag_update_ex(bmain, id_node->id_orig, DEG_TAG_COPY_ON_WRITE); } } - GHASH_FOREACH_END(); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 464a1454749..0c1a3d21f84 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -367,8 +367,7 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) { * them for new ID nodes. */ m_cow_id_hash = BLI_ghash_ptr_new("Depsgraph id hash"); - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, m_graph->id_hash) - { + foreach (IDDepsNode *id_node, m_graph->id_nodes) { if (GS(id_node->id_orig->name) != ID_SCE) { continue; } @@ -379,7 +378,6 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) { id_node->id_cow = NULL; } } - GHASH_FOREACH_END(); } /* Make sure graph has no nodes left from previous state. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index f2e155a66e6..91902ed0ea6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1990,11 +1990,9 @@ void DepsgraphRelationBuilder::build_lightprobe(Object *object) void DepsgraphRelationBuilder::build_copy_on_write_relations() { - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, m_graph->id_hash) - { + foreach (IDDepsNode *id_node, m_graph->id_nodes) { build_copy_on_write_relations(id_node); } - GHASH_FOREACH_END(); } void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node) diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc index ce3a4182a0f..618f4ced295 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc @@ -493,11 +493,9 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx, static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgraph *graph) { - GHASH_FOREACH_BEGIN (DepsNode *, node, graph->id_hash) - { + foreach (DepsNode *node, graph->id_nodes) { deg_debug_graphviz_node(ctx, node); } - GHASH_FOREACH_END(); TimeSourceDepsNode *time_source = graph->find_time_source(); if (time_source != NULL) { deg_debug_graphviz_node(ctx, time_source); @@ -507,8 +505,7 @@ static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const Depsgraph *graph) { - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash) - { + foreach (IDDepsNode *id_node, graph->id_nodes) { GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components) { foreach (OperationDepsNode *op_node, comp_node->operations) { @@ -517,7 +514,6 @@ static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, } GHASH_FOREACH_END(); } - GHASH_FOREACH_END(); TimeSourceDepsNode *time_source = graph->find_time_source(); if (time_source != NULL) { diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 05e66318d86..3caf7e5923f 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -314,8 +314,7 @@ void Depsgraph::clear_id_nodes() /* Free memory used by ID nodes. */ if (use_copy_on_write) { /* Stupid workaround to ensure we free IDs in a proper order. */ - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash) - { + foreach (IDDepsNode *id_node, id_nodes) { if (id_node->id_cow == NULL) { /* This means builder "stole" ownership of the copy-on-written * datablock for her own dirty needs. @@ -330,13 +329,10 @@ void Depsgraph::clear_id_nodes() id_node->destroy(); } } - GHASH_FOREACH_END(); } - GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash) - { + foreach (IDDepsNode *id_node, id_nodes) { OBJECT_GUARDED_DELETE(id_node, IDDepsNode); } - GHASH_FOREACH_END(); /* Clear containers. */ BLI_ghash_clear(id_hash, NULL, NULL); id_nodes.clear(); diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 70e08dbb449..dac084e4bad 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -198,8 +198,7 @@ void DEG_stats_simple(const Depsgraph *graph, size_t *r_outer, size_t tot_outer = 0; size_t tot_rels = 0; - GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, deg_graph->id_hash) - { + foreach (DEG::IDDepsNode *id_node, deg_graph->id_nodes) { tot_outer++; GHASH_FOREACH_BEGIN(DEG::ComponentDepsNode *, comp_node, id_node->components) { @@ -210,7 +209,6 @@ void DEG_stats_simple(const Depsgraph *graph, size_t *r_outer, } GHASH_FOREACH_END(); } - GHASH_FOREACH_END(); DEG::TimeSourceDepsNode *time_source = deg_graph->find_time_source(); if (time_source != NULL) { diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 39505d256ec..607ec675a39 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -367,8 +367,7 @@ void deg_id_tag_update(Main *bmain, ID *id, int flag) void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph) { /* Make sure objects are up to date. */ - GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash) - { + foreach (DEG::IDDepsNode *id_node, graph->id_nodes) { const ID_Type id_type = GS(id_node->id_orig->name); /* TODO(sergey): Special exception for now. */ if (id_type == ID_MSK) { @@ -390,7 +389,6 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph) } deg_graph_id_tag_update(bmain, graph, id_node->id_orig, flag); } - GHASH_FOREACH_END(); /* Make sure collection properties are up to date. */ for (Scene *scene_iter = graph->scene; scene_iter != NULL; scene_iter = scene_iter->set) { IDDepsNode *scene_id_node = graph->find_id_node(&scene_iter->id); |