Fix #109670: attribute shared between geometries even when edited #111514

Merged
Jacques Lucke merged 2 commits from JacquesLucke/blender:unshare-attribute-on-rna-access into main 2023-09-12 13:03:10 +02:00
Member

The RNA attribute API did not make sure that attributes are unshared when the data is accessed. This is necessary to avoid accidentally changing data on other geometries.

Unfortunately, we currently can't detect if the access is read-only or if the attribute data is modified. Therefore, the data is always copied when it was shared. This makes it a little bit less efficient in some cases, but that should still be ok. The old behavior could by brought back by implementing #112150.

The RNA attribute API did not make sure that attributes are unshared when the data is accessed. This is necessary to avoid accidentally changing data on other geometries. Unfortunately, we currently can't detect if the access is read-only or if the attribute data is modified. Therefore, the data is always copied when it was shared. This makes it a little bit less efficient in some cases, but that should still be ok. The old behavior could by brought back by implementing #112150.
Jacques Lucke added 1 commit 2023-08-25 12:20:32 +02:00
fix
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
c362cdd0c5
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Brecht Van Lommel 2023-08-25 12:21:38 +02:00
Jacques Lucke requested review from Hans Goudey 2023-08-25 12:21:38 +02:00
Member

It's too bad this will affect Cycles, but maybe we can move Cycles to use the C++ attribute API (not RNA) for 4.0.

It's too bad this will affect Cycles, but maybe we can move Cycles to use the C++ attribute API (not RNA) for 4.0.
Jacques Lucke added 1 commit 2023-08-31 12:44:44 +02:00
Merge branch 'main' into unshare-attribute-on-rna-access
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
6bea2fadf6
Author
Member

@blender-bot build

@blender-bot build
Member

I know this is a fix, but I'm a little hesitant to accept this before we have at least some idea of how const correctness and implicit sharing should work properly with the RNA API. Do you have any thoughts about that? I thought making the Python API look more like the AttributeReader and AttributeWriter classes would make sense. But I'm not sure if that sort of const correctness is typical in Python or if things are just expected to be more explicit.

I know this is a fix, but I'm a little hesitant to accept this before we have at least some idea of how const correctness and implicit sharing should work properly with the RNA API. Do you have any thoughts about that? I thought making the Python API look more like the `AttributeReader` and `AttributeWriter` classes would make sense. But I'm not sure if that sort of const correctness is typical in Python or if things are just expected to be more explicit.
Author
Member

We'll probably have to add a way to get read-only access to attributes at some point (e.g. attribute.data_readonly). I don't think it's worth breaking the api over this. It's also less common for things to be readonly that could also be mutable in Python, so making read-only the special case probably makes sense from a Python API perspectice.

We'll probably have to add a way to get read-only access to attributes at some point (e.g. `attribute.data_readonly`). I don't think it's worth breaking the api over this. It's also less common for things to be readonly that could also be mutable in Python, so making read-only the special case probably makes sense from a Python API perspectice.
Hans Goudey approved these changes 2023-09-07 21:23:00 +02:00
Hans Goudey left a comment
Member

I'd like to consider Brecht's review blocking here, but this is okay with me. Can you create a followup task for .data_readonly just so we have that written down somewhere and we can point to it?

I'll change Cycles to use the C++ API directly for attributes in after this lands, since I don't want that to get slower.

I'd like to consider Brecht's review blocking here, but this is okay with me. Can you create a followup task for `.data_readonly` just so we have that written down somewhere and we can point to it? I'll change Cycles to use the C++ API directly for attributes in after this lands, since I don't want that to get slower.
Author
Member

I created #112150 as a follow up task.

I created #112150 as a follow up task.
Brecht Van Lommel approved these changes 2023-09-12 12:29:53 +02:00
Brecht Van Lommel left a comment
Owner

Not ideal but I don't have a better solution without significant API changes.

Not ideal but I don't have a better solution without significant API changes.
Jacques Lucke merged commit 34b4487844 into main 2023-09-12 13:03:10 +02:00
Jacques Lucke deleted branch unshare-attribute-on-rna-access 2023-09-12 13:03:12 +02:00
First-time contributor

I had been using a mode]al operator to using mouse / keyboard / joysticks to interact with a running simulation

I can't interact with the sim in py at all now without using a second mesh / passing in data that way - breaking any sort of ability to duplicate a setup.

I had been using a mode]al operator to using mouse / keyboard / joysticks to interact with a running simulation I can't interact with the sim in py at all now without using a second mesh / passing in data that way - breaking any sort of ability to duplicate a setup.
Sign in to join this conversation.
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111514
No description provided.