From 0e37d3efc017151309b272e4562edd901bfbde7a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 28 Jan 2021 13:36:23 +0100 Subject: Fix T84717: missing 3D viewport updates when changing shading settings Previously this relied on the dependency graph to detect changes in the screen datablock, which would then notify the renderers. This was rather indirect an not even really by design. Instead use notifiers to tag specific 3D viewports to be updated. Includes changes to BKE_scene_get_depsgraph to accept a const Scene pointer. Testing if this works correctly requires adding back commits 81d444c and 088904d, since those have been temporarily reverted. Differential Revision: https://developer.blender.org/D10235 --- source/blender/depsgraph/DEG_depsgraph.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 0ded511b8f8..567916fdebe 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -175,7 +175,8 @@ typedef struct DEGEditorUpdateContext { } DEGEditorUpdateContext; typedef void (*DEG_EditorUpdateIDCb)(const DEGEditorUpdateContext *update_ctx, struct ID *id); -typedef void (*DEG_EditorUpdateSceneCb)(const DEGEditorUpdateContext *update_ctx, int updated); +typedef void (*DEG_EditorUpdateSceneCb)(const DEGEditorUpdateContext *update_ctx, + const bool updated); /* Set callbacks which are being called when depsgraph changes. */ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, DEG_EditorUpdateSceneCb scene_func); -- cgit v1.2.3 From 876fd40643dfa7b206edabbde30809e6e48e583b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Jan 2021 14:16:10 +0100 Subject: Fix T83411: Crash when using a workspace/layout data path in a driver Building IDs which are not covered by copy-on-write process was not implemented, which was causing parameters block not present, and, hence causing crashes in areas which expected parameters to present. First part of this change is related on making it so Copy-on-Write is optional for ID nodes in the dependency graph. Second part is related on using a generic builder for all ID types which were not covered by Copy-on-Write before. The final part is related on making it so build_id() is properly handling ParticleSettings and Grease Pencil Data. Before they were not covered there at all, and they need special handling because they do have own build functions. Not sure it worth trying to split those parts, as they are related to each other and are not really possible to be tested standalone. Open for a second opinion though. Possible nut-tightening is to re-organize build_id() function so that every branch does return and have an assert at the end, so that missing ID type in the switch statement is easier to spot even when using compilers which do not report missing switch cases. As for question "why not use default" the answer is: to make it more explicit and clear what is a decision when adding new ID types. We do not want to quietly fall-back to a non-copy-on-write case for a newly added ID types. Differential Revision: https://developer.blender.org/D10075 --- .../depsgraph/intern/builder/deg_builder_nodes.cc | 36 ++++++++++++++++++--- .../depsgraph/intern/builder/deg_builder_nodes.h | 3 ++ .../intern/builder/deg_builder_relations.cc | 37 +++++++++++++++++++--- .../intern/builder/deg_builder_relations.h | 3 ++ 4 files changed, 71 insertions(+), 8 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 2edd4ddf853..b0a5f1a34d6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -388,7 +388,9 @@ void DepsgraphNodeBuilder::build_id(ID *id) if (id == nullptr) { return; } - switch (GS(id->name)) { + + const ID_Type id_type = GS(id->name); + switch (id_type) { case ID_AC: build_action((bAction *)id); break; @@ -478,13 +480,39 @@ void DepsgraphNodeBuilder::build_id(ID *id) case ID_SIM: build_simulation((Simulation *)id); break; - default: - fprintf(stderr, "Unhandled ID %s\n", id->name); - BLI_assert(!"Should never happen"); + case ID_PA: + build_particle_settings((ParticleSettings *)id); + break; + case ID_GD: + build_gpencil((bGPdata *)id); + break; + + case ID_LI: + case ID_IP: + case ID_SCR: + case ID_VF: + case ID_BR: + case ID_WM: + case ID_PAL: + case ID_PC: + case ID_WS: + BLI_assert(!deg_copy_on_write_is_needed(id_type)); + build_generic_id(id); break; } } +void DepsgraphNodeBuilder::build_generic_id(ID *id) +{ + if (built_map_.checkIsBuiltAndTag(id)) { + return; + } + + build_idproperties(id->properties); + build_animdata(id); + build_parameters(id); +} + static void build_idproperties_callback(IDProperty *id_property, void *user_data) { DepsgraphNodeBuilder *builder = reinterpret_cast(user_data); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 174f9b129f9..a7033c8c8f3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -152,6 +152,9 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { virtual void build_id(ID *id); + /* Build function for ID types that do not need their own build_xxx() function. */ + virtual void build_generic_id(ID *id); + virtual void build_idproperties(IDProperty *id_property); virtual void build_scene_render(Scene *scene, ViewLayer *view_layer); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index ed78956e548..3c42f0f0612 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -491,7 +491,9 @@ void DepsgraphRelationBuilder::build_id(ID *id) if (id == nullptr) { return; } - switch (GS(id->name)) { + + const ID_Type id_type = GS(id->name); + switch (id_type) { case ID_AC: build_action((bAction *)id); break; @@ -567,13 +569,40 @@ void DepsgraphRelationBuilder::build_id(ID *id) case ID_SIM: build_simulation((Simulation *)id); break; - default: - fprintf(stderr, "Unhandled ID %s\n", id->name); - BLI_assert(!"Should never happen"); + case ID_PA: + build_particle_settings((ParticleSettings *)id); + break; + case ID_GD: + build_gpencil((bGPdata *)id); + break; + + case ID_LI: + case ID_IP: + case ID_SCR: + case ID_VF: + case ID_BR: + case ID_WM: + case ID_PAL: + case ID_PC: + case ID_WS: + BLI_assert(!deg_copy_on_write_is_needed(id_type)); + build_generic_id(id); break; } } +void DepsgraphRelationBuilder::build_generic_id(ID *id) +{ + + if (built_map_.checkIsBuiltAndTag(id)) { + return; + } + + build_idproperties(id->properties); + build_animdata(id); + build_parameters(id); +} + static void build_idproperties_callback(IDProperty *id_property, void *user_data) { DepsgraphRelationBuilder *builder = reinterpret_cast(user_data); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 5587379089c..21d1d4b6268 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -198,6 +198,9 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder { virtual void build_id(ID *id); + /* Build function for ID types that do not need their own build_xxx() function. */ + virtual void build_generic_id(ID *id); + virtual void build_idproperties(IDProperty *id_property); virtual void build_scene_render(Scene *scene, ViewLayer *view_layer); -- cgit v1.2.3 From b3fc88554468eb91fac3c2afb9387e599e6db507 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Jan 2021 10:17:01 +0100 Subject: Depsgraph: Remove redundant copy-on-write operations This change removes copy-on-write operations from ID nodes which do not need copy-on-write. Should be no functional changes, as before the copy-on-write operation would do nothing for those nodes anyway. --- source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 7 +++---- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index b0a5f1a34d6..c3304cd80ff 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -155,6 +155,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id) { BLI_assert(id->session_uuid != MAIN_ID_SESSION_UUID_UNSET); + const ID_Type id_type = GS(id->name); IDNode *id_node = nullptr; ID *id_cow = nullptr; IDComponentsMask previously_visible_components_mask = 0; @@ -173,10 +174,8 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id) id_node->previously_visible_components_mask = previously_visible_components_mask; id_node->previous_eval_flags = previous_eval_flags; id_node->previous_customdata_masks = previous_customdata_masks; - /* Currently all ID nodes are supposed to have copy-on-write logic. - * - * NOTE: Zero number of components indicates that ID node was just created. */ - if (id_node->components.is_empty()) { + /* NOTE: Zero number of components indicates that ID node was just created. */ + if (id_node->components.is_empty() && deg_copy_on_write_is_needed(id_type)) { ComponentNode *comp_cow = id_node->add_component(NodeType::COPY_ON_WRITE); OperationNode *op_cow = comp_cow->add_operation( function_bind(deg_evaluate_copy_on_write, _1, id_node), diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 3c42f0f0612..463efe52375 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2834,7 +2834,13 @@ void DepsgraphRelationBuilder::build_nested_shapekey(ID *owner, Key *key) void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) { ID *id_orig = id_node->id_orig; + const ID_Type id_type = GS(id_orig->name); + + if (!deg_copy_on_write_is_needed(id_type)) { + return; + } + TimeSourceKey time_source_key; OperationKey copy_on_write_key(id_orig, NodeType::COPY_ON_WRITE, OperationCode::COPY_ON_WRITE); /* XXX: This is a quick hack to make Alt-A to work. */ -- cgit v1.2.3