Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2022-01-25 16:51:35 +0300
committerJeroen Bakker <jeroen@blender.org>2022-01-26 13:12:35 +0300
commita21bca0e20a05177f514e703bd99a929d5349034 (patch)
tree339a761ddc65cd293dc0052c401f87538e53f6e8 /source/blender/editors/space_node/space_node.cc
parentb3bf46b78daca91cc73b3f4ac43ad7e9d86a4413 (diff)
Performance: Remap multiple items in UI
During sprite fright loading of complex scenes would spend a long time in remapping ID's The remapping process is done on a per ID instance that resulted in a very time consuming process that goes over every possible ID reference to find out if it needs to be updated. If there are N of references to ID blocks and there are M ID blocks that needed to be remapped it would take N*M checks. These checks are scattered around the place and memory. Each reference would only be updated at most once, but most of the time no update is needed at all. Idea: By grouping the changes together will reduce the number of checks resulting in improved performance. This would only require N checks. Additional benefits is improved data locality as data is only loaded once in the L2 cache. It has be implemented for the resyncing process and UI editors. On an Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz 16Gig the resyncing process went from 170 seconds to 145 seconds (during hotspot recording). After this patch has been applied we could add similar approach to references (references between data blocks) and functionality (tagged deletion). In my understanding this could reduce the resyncing process to less than a second. Opening the village production file between 10 and 20 seconds. Flame graphs showing that UI remapping isn't visible anymore (`WM_main_remap_editor_id_reference`) * Master {F12769210 size=full} * This patch {F12769211 size=full} Reviewed By: mont29 Maniphest Tasks: T94185 Differential Revision: https://developer.blender.org/D13615
Diffstat (limited to 'source/blender/editors/space_node/space_node.cc')
-rw-r--r--source/blender/editors/space_node/space_node.cc83
1 files changed, 38 insertions, 45 deletions
diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc
index f794a8ce294..8f465ffbf80 100644
--- a/source/blender/editors/space_node/space_node.cc
+++ b/source/blender/editors/space_node/space_node.cc
@@ -31,6 +31,7 @@
#include "BKE_context.h"
#include "BKE_lib_id.h"
+#include "BKE_lib_remap.h"
#include "BKE_node.h"
#include "BKE_screen.h"
@@ -896,71 +897,63 @@ static void node_widgets()
WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_corner_pin);
}
-static void node_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
+static void node_id_remap(ScrArea *UNUSED(area),
+ SpaceLink *slink,
+ const struct IDRemapper *mappings)
{
SpaceNode *snode = (SpaceNode *)slink;
- if (snode->id == old_id) {
+ if (ELEM(BKE_id_remapper_apply(mappings, &snode->id, ID_REMAP_APPLY_DEFAULT),
+ ID_REMAP_RESULT_SOURCE_REMAPPED,
+ ID_REMAP_RESULT_SOURCE_UNASSIGNED)) {
/* nasty DNA logic for SpaceNode:
* ideally should be handled by editor code, but would be bad level call
*/
BLI_freelistN(&snode->treepath);
/* XXX Untested in case new_id != nullptr... */
- snode->id = new_id;
snode->from = nullptr;
snode->nodetree = nullptr;
snode->edittree = nullptr;
}
- else if (GS(old_id->name) == ID_OB) {
- if (snode->from == old_id) {
- if (new_id == nullptr) {
- snode->flag &= ~SNODE_PIN;
- }
- snode->from = new_id;
- }
+ if (BKE_id_remapper_apply(mappings, &snode->from, ID_REMAP_APPLY_DEFAULT) ==
+ ID_REMAP_RESULT_SOURCE_UNASSIGNED) {
+ snode->flag &= ~SNODE_PIN;
}
- else if (GS(old_id->name) == ID_GD) {
- if ((ID *)snode->gpd == old_id) {
- snode->gpd = (bGPdata *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
- }
+ BKE_id_remapper_apply(mappings, (ID **)&snode->gpd, ID_REMAP_APPLY_UPDATE_REFCOUNT);
+
+ if (!BKE_id_remapper_has_mapping_for(mappings, FILTER_ID_NT)) {
+ return;
}
- else if (GS(old_id->name) == ID_NT) {
- bNodeTreePath *path, *path_next;
- for (path = (bNodeTreePath *)snode->treepath.first; path; path = path->next) {
- if ((ID *)path->nodetree == old_id) {
- path->nodetree = (bNodeTree *)new_id;
- id_us_ensure_real(new_id);
- }
- if (path == snode->treepath.first) {
- /* first nodetree in path is same as snode->nodetree */
- snode->nodetree = path->nodetree;
- }
- if (path->nodetree == nullptr) {
- break;
- }
+ bNodeTreePath *path, *path_next;
+ for (path = (bNodeTreePath *)snode->treepath.first; path; path = path->next) {
+ BKE_id_remapper_apply(mappings, (ID **)&path->nodetree, ID_REMAP_APPLY_ENSURE_REAL);
+ if (path == snode->treepath.first) {
+ /* first nodetree in path is same as snode->nodetree */
+ snode->nodetree = path->nodetree;
+ }
+ if (path->nodetree == nullptr) {
+ break;
}
+ }
- /* remaining path entries are invalid, remove */
- for (; path; path = path_next) {
- path_next = path->next;
+ /* remaining path entries are invalid, remove */
+ for (; path; path = path_next) {
+ path_next = path->next;
- BLI_remlink(&snode->treepath, path);
- MEM_freeN(path);
- }
+ BLI_remlink(&snode->treepath, path);
+ MEM_freeN(path);
+ }
- /* edittree is just the last in the path,
- * set this directly since the path may have been shortened above */
- if (snode->treepath.last) {
- path = (bNodeTreePath *)snode->treepath.last;
- snode->edittree = path->nodetree;
- }
- else {
- snode->edittree = nullptr;
- }
+ /* edittree is just the last in the path,
+ * set this directly since the path may have been shortened above */
+ if (snode->treepath.last) {
+ path = (bNodeTreePath *)snode->treepath.last;
+ snode->edittree = path->nodetree;
+ }
+ else {
+ snode->edittree = nullptr;
}
}