Subject: [PATCH 2/3] Depsgraph: Replace iteration over ghash with iteration over flat array
This commit is contained in:
parent
10f076da2d
commit
19c14f0c8a
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue