Geometry Nodes: refactor storage for socket values #116231
No reviewers
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116231
Loading…
Reference in New Issue
No description provided.
Delete Branch "JacquesLucke/blender:generic-socket-value-variant"
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 refactors
SocketValueVariant
with the following goals in mind:SocketValueVariant
have to know about all the types sockets can have.SocketValueVariantCPPType
a lot to manage uninitialized memory. This is better abstracted away now.One related change that I had to do that I didn't see coming at first was that I had to refactor
set_default_remaining_outputs
because now the default value of aSocketValueVariant
would not contain any value. Previously, it was initialized the zero-value of the template parameter. Similarly, I had to change how implicit conversions are created, because comparing theCPPType
of linked sockets was not enough anymore to determine if a conversion is necessary.We could potentially use
SocketValueVariant
for the remaining socket types in the future as well. Not entirely sure if that helps yet.SocketValueVariant
can easily be adapted to make that work though. That would also justify the name "SocketValueVariant" better.@blender-bot build
Looks great overall, especially how we can pass the type and the value with one variable now. Just a couple points inline.
Out of curiosity, did you test to see if there was a performance impact in some of the test files that emphasize per-node overhead?
@ -9,3 +9,3 @@
#pragma once
#include "FN_field.hh"
#include "DNA_node_types.h"
DNA_node_types.h
is a pretty large header, might be nice to avoid including it everywhere just foreNodeSocketDatatype
. In practice it's probably already included nearly everywhere anyway, but in principle it's nice to avoid this. A few potential solutions for that I think:enum class
at the same timeenum class :int8_t
in DNA so we can use forward declarations.DNA_node_enums.h
similar to other DNA headers (that's probably simplest to do for now)Long as we agree on one of them, seems fine not to do anything for this PR :)
I think the right solution is to split up dna headers.
@ -15,2 +19,2 @@
/* -------------------------------------------------------------------- */
/** \name Value or Field Class
/**
* #SocketValueVariant is used by geometry nodes to pass data between nodes. Specifically, it is
Maybe
used by the lazy function evaluator (geometry nodes)
to help justify the generic name of the file?@ -64,0 +118,4 @@
bool is_context_dependent_field() const;
/**
* Cnvert the stored value into a single value. For simple value access, this is not necessary,
Cnvert
->Convert
@ -315,3 +315,2 @@
{
BLI_assert(this->is<T>());
return *static_cast<std::decay_t<T> *>(this->get());
return const_cast<T &>(const_cast<const Any *>(this)->get<T>());
Would like to see some justification of the const casts in a comment, it's raising my eyebrows right now otherwise.
@ -382,0 +382,4 @@
/**
* Outputs the default value of each output socket that has not been output yet.
*/
void set_default_remaining_node_outputs(lf::Params ¶ms, const bNode &node);
Why does this have to work at the
bNode
level now? I'd think it could just use the lazy function directly. Maybe that's what you're getting at in the description, but I don't see how that leads to this now.Right now I'm measuring about 5% slowdown in the many math nodes benchmark (with ~400k math node evaluations on single values). The seems to be mostly caused by conversions between socket and cpp types. I think we can probably optimize those away for the most part by spending some time optimizing the individual uses of
get_single_ptr
andnew_single_for_write
.