Decide and Implement which level of code is responsible for Depsgraph Tagging #116601
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116601
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Current code is very inconsistent regarding which level of code is responsible to tag an ID for depsgraph updates when it gets modified.
A simple example:
BKE_collection_object_add
will tag the affected parent collection, whileBKE_collection_add
will not.So depending on which BKE function some higher-level of code uses (like RNA, Editor, I/O, etc.), it has to guess or search whether it should handle depsgraph tagging or not.
Proposal:
In general, do not handle depsgraph tagging in BKE API code. When some BKE code does, it should be clearly documented, and in some cases it may allow disabling it as an option.
Rational:
G_MAIN
database. In fact, it is likely to be less and less true in the future, as we work toward better support for off-main and temp-main data handling.Exceptions:
ID_REMAP_SKIP_UPDATE_TAGGING
) can be used then to optionally disable that tagging.@brecht @Sergey @JacquesLucke thoughts?
The issue with moving it out of BKE API functions is that the tagging can be conditional on exactly what the function did, or may involve tagging other datablocks. And even in simpler cases, it feels weak to have a hidden dependency between what the BKE function does exactly and the appropriate corresponding depsgraph tag to use outside of it.
I would prefer to have the code that modifies the struct member and the corresponding tagging to be as close to each other as possible. For efficiency that is not always possible, but to me it seems those cases should be the exception where we have to be careful, and in others we keep them together.
However calling the depsgraph tag function is inefficient and so doing it in lower level API functions is not great now.
What I would like to move to eventually is to replace depsgraph tagging with setting a flag on datablocks as they are modified. This would then be flushed to the relevant depsgraphs later, and would also be used to make for example undo writing more efficient by skipping unmodified datablocks.
Fair enough, I can understand how that would be good too. But then, what about operations on IDs that do not belong to
G_MAIN
? Currently, depsgraph tagging essentially assumes that it's operating onG_MAIN
data (in 99% of cases). Do we accept this fuzzyness/extra 'useless' processing when IDs do not belong to main data?That indeed sounds like a nice idea. Where would you do the flushing then? Before (or even as part of) depsgraph update calls? And before global undo pushes?
In theory, we could already skip writing of unmodified IDs, since deg tags are written on IDs too, and are used for the partial depsgraph update when loading an undo step. Would not consider this seriously currently though, since am fairly certain that we are still missing a lot of correct tagging when modifying data... This gets relatively unnoticed because updates happen from other sources most of the time. We'd need some sort of debug assert that all edits get properly tagged, but not sure how to do that currently. And some ID types are ignored by the depsgraph currently (like Text...).
Yes, I think we would. Maybe there will even be a use in some cases, though not immediately sure.
It would be right before depsgraph updates. There are some details to be worked out in terms of how you can use the same tag for multiple purposes, maybe it needs separate flags. Also how to do it efficiently without having to loop over all datablocks if nothing changed.
Yes, it's a risky change and would need extensive testing with asserts like that.
There are UI properties on datablocks that don't get a depsgraph tag on changes, and datablocks like images that don't use copy on write and so also do not get tagged always. So the meaning needs to be changed a bit from
DEG_id_tag_update
toID_tag_modified
.OK, so for the time being I will start fixing cases like
BKE_collection_add
missing proper tagging when I find them.The whole tagging refactor will need its own design task anyway.
We could definitely look into making tagging a cheaper operation. However, it is not THAT expensive, and a lot of low-level code already does tagging at a low level.
Doing tag at the place where thing is modified makes overall system so much more reliable.
P.S. It is something we've talked with Bastien IRL, but thought it worth stating here explicitly.