WIP: Core: experiment for embedding linked data-blocks #128545
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#128545
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "JacquesLucke/blender:embedded-linked"
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?
This is an initial experiment for storing linked data-blocks in the .blend that links them. This functionality for implementing is a prerequisite for implementing #125389 in a way that keeps embedded data-blocks linked.
Currently, this patch just treats all linked data-blocks as embedded for simplicity. It seems to work for the simple case I tested. I have a bit of a hard time reasoning about how it behaves with recursively linked data when when embedded data-blocks are linked. Another tricky aspect is that versioning of the embedded data has to happen together with the other local data and not together with the other data from the linked library.
Based on a recent discussion with Dalai, Simon and Pablo, I'm currently using the terms "static linking" and "dynamic linking" in the code. "Dynamic" means that the source data-block is loaded from the source file, and "static" that the data-block is embedded.
I'm posting this here to get some initial feedback on the approach which likely is way to simplistic so far.
The patch also contains a debug utility that I originally wrote for #127729. It servers a similar purpose as
blend2json.py
but produces more useful data for me right now. It just stores a*.debug.txt
file next to every saved.blend
file.@blender-bot build
Thanks for this initial prototype! Seems to be simple enough and going into the right direction.
Layout of Embedded Linked IDs in Blendfile
The biggest change I would suggest in this initial protoype is how/where embedded linked IDs are stored.
I think they should rather be stored together with the placeholders of regular directly linked IDs, after their
Library
data-block:lib
pointer tocurrlib
).write_libraries
to not only write placeholders, but also complete ID data in the embedded case.All in all, I would find this structure more logical (it would also somewhat match how packed libraries are stored), and again, hopefully makes these embedded IDs 'transparently' load as regular linked IDs in older Blenders.
Versionning
We are going to have a fun time managing the fact that IDs belonging to a given file (a library) may have been written by a different version of Blender (in the blendfile using that library).
one solution could be to store the blendfile version in the ID runtime data itself (during initila reading of the ID in readfile code). However, that would require a complete change in how we handle versioning.
Another solution could be to split each library data in more that one
Main
data-base for the versioning process, based on the version of the actual blendfile from which the ID data comes from. Or have a different variant ofblo_split_main
, that would generate Mains based on actual blendfile source of the data, and not the 'owner' libraries...Naming
I would very much like to be part of these discussions, as this is technical topic way more than PR/UX topic. And I strongly disagree with the current naming proposal, would much rather stick to naming used in the design task (just
linking
for regular linking data, andembedded linking
for new worked-on sub-type of linking):@ -3579,2 +3586,4 @@
}
/* Used to keep track of data-blocks that were statically linked. */
blender::MultiValueMap<const void *, ID *> static_linked_data_blocks_by_old_library;
If embedded IDs are written as part of their library in blendfile, there should not be any need for this mapping?
@ -3707,3 +3723,3 @@
blo_split_main(&mainlist, bfd->main);
LISTBASE_FOREACH (Main *, mainvar, &mainlist) {
BLI_assert(mainvar->versionfile != 0);
if (mainvar->versionfile == 0) {
This is going to be an interesting topic to get right. We'll need a way to differentiate the handling of these IDs now, since regular linked one need to be processed according to their source lib blendfile version, while embedded ones need to be handled according to their owning user blendfile version (which may also be a library btw ;) ).
Might end up being simpler to store the 'source version' in each ID runtime data, rather than trying to keep track of this?
@ -1279,3 +1287,3 @@
}
if (cb_flag & IDWALK_CB_DIRECT_WEAK_LINK) {
if (cb_flag & IDWALK_CB_DIRECT_WEAK_LINK && ID_IS_DYNAMIC_LINKED(id)) {
Would not check this here, but rather update code of
id_lib_indirect_weak_link
itself to handle (ignore in fact) embedded linked IDs.@ -1381,3 +1391,3 @@
* then the temp ones from override process,
* if needed, without duplicating whole code. */
Main *bmain = mainvar;
blender::Vector<Main *> bmains;
Don't think that writing embedded linked IDs together with actual local data is a good idea. Would rather write them as part of their libraries.
@ -1384,0 +1394,4 @@
LISTBASE_FOREACH (Main *, bmain, &mainlist) {
bmains.append(bmain);
}
if (override_storage) {
This is fairly theoretical currently, but the
override_storage
should be written immediately after the 'local'main
(i.e. in second position in thebmains
vector), since it also contains purely local IDs.@ -1386,3 +1401,4 @@
for (Main *bmain : bmains) {
ListBase *lbarray[INDEX_ID_MAX];
int a = set_listbasepointers(bmain, lbarray);
while (a--) {
I would move most of the code in this loop into a new utils (something like
write_id
). Then this can be called both from here for actual local IDs, and fromwrite_libraries
for embedded linked data.Would even do that as a separate 'refactor' PR to get it in
main
asap and reduce diffing noise in actual PR?@ -652,6 +652,8 @@ typedef struct PreviewImage {
#define ID_MISSING(_id) ((((const ID *)(_id))->tag & ID_TAG_MISSING) != 0)
#define ID_IS_LINKED(_id) (((const ID *)(_id))->lib != NULL)
#define ID_IS_DYNAMIC_LINKED(_id) (false)
Would rather only have anew
ID_IS_LINKED_EMBEDDED
for the time being, and check!ID_IS_LINKED_EMBEDDED
when only handling 'regular' linked data is needed.Checkout
From your project repository, check out a new branch and test the changes.