diff options
Diffstat (limited to 'source/blender/depsgraph/intern/nodes')
6 files changed, 78 insertions, 25 deletions
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc index 548911dcfa9..5e7ed249365 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node.cc @@ -128,8 +128,8 @@ IDDepsNode::ComponentIDKey::ComponentIDKey(eDepsNode_Type type, bool IDDepsNode::ComponentIDKey::operator== (const ComponentIDKey &other) const { - return type == other.type && - STREQ(name, other.name); + return type == other.type && + STREQ(name, other.name); } static unsigned int id_deps_node_hash_key(const void *key_v) @@ -165,24 +165,43 @@ static void id_deps_node_hash_value_free(void *value_v) /* Initialize 'id' node - from pointer data given. */ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata)) { - /* Store ID-pointer. */ BLI_assert(id != NULL); - this->id_orig = (ID *)id; - this->eval_flags = 0; + /* Store ID-pointer. */ + id_orig = (ID *)id; + eval_flags = 0; components = BLI_ghash_new(id_deps_node_hash_key, id_deps_node_hash_key_cmp, "Depsgraph id components hash"); +} +void IDDepsNode::init_copy_on_write(ID *id_cow_hint) +{ #ifdef WITH_COPY_ON_WRITE /* Create pointer as early as possible, so we can use it for function * bindings. Rest of data we'll be copying to the new datablock when * it is actually needed. */ - id_cow = (ID *)BKE_libblock_alloc_notest(GS(id->name)); - DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n", - id_orig->name, id_orig, id_cow); + if (id_cow_hint != NULL) { + // BLI_assert(deg_copy_on_write_is_needed(id_orig)); + if (deg_copy_on_write_is_needed(id_orig)) { + id_cow = id_cow_hint; + } + else { + id_cow = id_orig; + } + } + else if (deg_copy_on_write_is_needed(id_orig)) { + id_cow = (ID *)BKE_libblock_alloc_notest(GS(id_orig->name)); + DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n", + id_orig->name, id_orig, id_cow); + deg_tag_copy_on_write_id(id_cow, id_orig); + } + else { + id_cow = id_orig; + } #else + UNUSED_VARS(id_cow_hint); id_cow = id_orig; #endif } @@ -190,17 +209,30 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata)) /* Free 'id' node. */ IDDepsNode::~IDDepsNode() { + destroy(); +} + +void IDDepsNode::destroy() +{ + if (id_orig == NULL) { + return; + } + BLI_ghash_free(components, id_deps_node_hash_key_free, id_deps_node_hash_value_free); #ifdef WITH_COPY_ON_WRITE /* Free memory used by this CoW ID. */ - deg_free_copy_on_write_datablock(id_cow); - MEM_freeN(id_cow); - DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n", - id_orig->name, id_orig, id_cow); + if (id_cow != id_orig && id_cow != NULL) { + deg_free_copy_on_write_datablock(id_cow); + MEM_freeN(id_cow); + DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n", + id_orig->name, id_orig, id_cow); + } #endif + /* Tag that the node is freed. */ + id_orig = NULL; } ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type, @@ -239,6 +271,23 @@ void IDDepsNode::tag_update(Depsgraph *graph) do_component_tag = true; } } + else if (comp_node->type == DEG_NODE_TYPE_SHADING) { + /* TODO(sergey): For until we properly handle granular flags for DEG_id_tag_update() + * we skip flushing here to keep Luca happy. + */ + if (GS(id_orig->name) != ID_MA && + GS(id_orig->name) != ID_WO) + { + do_component_tag = false; + } + } + else if (comp_node->type == DEG_NODE_TYPE_SHADING_PARAMETERS) { + do_component_tag = false; + } + else if (comp_node->type == DEG_NODE_TYPE_EVAL_PARTICLES) { + /* Only do explicit particle settings tagging. */ + do_component_tag = false; + } if (do_component_tag) { comp_node->tag_update(graph); } diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h index 4e03072d486..16e75b2b5e7 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node.h +++ b/source/blender/depsgraph/intern/nodes/deg_node.h @@ -138,7 +138,9 @@ struct IDDepsNode : public DepsNode { }; void init(const ID *id, const char *subdata); + void init_copy_on_write(ID *id_cow_hint = NULL); ~IDDepsNode(); + void destroy(); ComponentDepsNode *find_component(eDepsNode_Type type, const char *name = "") const; diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index bd9583a7b67..a250dce1239 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -396,6 +396,11 @@ static DepsNodeFactoryImpl<ParticlesComponentDepsNode> DNTI_EVAL_PARTICLES; DEG_DEPSNODE_DEFINE(ShadingComponentDepsNode, DEG_NODE_TYPE_SHADING, "Shading Component"); static DepsNodeFactoryImpl<ShadingComponentDepsNode> DNTI_SHADING; +/* Shading Parameters Component Defines ============================ */ + +DEG_DEPSNODE_DEFINE(ShadingParametersComponentDepsNode, DEG_NODE_TYPE_SHADING_PARAMETERS, "Shading Parameters Component"); +static DepsNodeFactoryImpl<ShadingParametersComponentDepsNode> DNTI_SHADING_PARAMETERS; + /* Cache Component Defines ============================ */ DEG_DEPSNODE_DEFINE(CacheComponentDepsNode, DEG_NODE_TYPE_CACHE, "Cache Component"); @@ -426,7 +431,9 @@ void deg_register_component_depsnodes() deg_register_node_typeinfo(&DNTI_BONE); deg_register_node_typeinfo(&DNTI_EVAL_PARTICLES); + deg_register_node_typeinfo(&DNTI_SHADING); + deg_register_node_typeinfo(&DNTI_SHADING_PARAMETERS); deg_register_node_typeinfo(&DNTI_CACHE); diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 955d197b33a..d2a375421fd 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -151,6 +151,7 @@ struct ComponentDepsNode : public DepsNode { OperationDepsNode *exit_operation; // XXX: a poll() callback to check if component's first node can be started? + virtual bool depends_on_cow() { return true; } }; /* ---------------------------------------- */ @@ -200,6 +201,11 @@ struct ShadingComponentDepsNode : public ComponentDepsNode { DEG_DEPSNODE_DECLARE; }; +struct ShadingParametersComponentDepsNode : public ComponentDepsNode { + DEG_DEPSNODE_DECLARE; + virtual bool depends_on_cow() { return false; } +}; + struct CacheComponentDepsNode : public ComponentDepsNode { DEG_DEPSNODE_DECLARE; }; @@ -210,6 +216,8 @@ struct LayerCollectionsDepsNode : public ComponentDepsNode { struct CopyOnWriteDepsNode : public ComponentDepsNode { DEG_DEPSNODE_DECLARE; + + virtual bool depends_on_cow() { return false; } }; diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc index 84b3d33f494..7467264f612 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc @@ -76,9 +76,6 @@ string OperationDepsNode::full_identifier() const void OperationDepsNode::tag_update(Depsgraph *graph) { - if (flag & DEPSOP_FLAG_SKIP_FLUSH) { - flag &= ~DEPSOP_FLAG_SKIP_FLUSH; - } if (flag & DEPSOP_FLAG_NEEDS_UPDATE) { return; } diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h index 8a1fadd9c6c..d8203540fc5 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h @@ -45,16 +45,6 @@ typedef enum eDepsOperation_Flag { /* node was directly modified, causing need for update */ DEPSOP_FLAG_DIRECTLY_MODIFIED = (1 << 1), - - /* Operation is evaluated using CPython; has GIL and security - * implications... - */ - DEPSOP_FLAG_USES_PYTHON = (1 << 2), - - /* Special flag which indicates that update tag sohuld not be flushed - * up to the dependent nodes. - */ - DEPSOP_FLAG_SKIP_FLUSH = (1 << 3), } eDepsOperation_Flag; /* Atomic Operation - Base type for all operations */ |