Geometry Nodes: use lazy-function directly for switch node #105696

Merged
Jacques Lucke merged 9 commits from JacquesLucke/blender:switch-node-separate-api into main 2023-03-14 14:09:39 +01:00
Member

This changes the Switch node so that it is implemented directly as a lazy-function, instead of as a normal geometry node which uses GeoNodeExecParams. This improves the design of the layered execution api, where different nodes can be implemented at a proper different abstraction level. The simplest kinds of nodes are implemented as multi-function, then there is GeoNodeExecParams and more specialized nodes are implemented as lazy-function. The switch node is special in the sense that it currently needs extra behavior in the lazy-function graph generation anyway.

GeoNodeExecParams can be simplified as well, because the Switch node was the only one that used the lazy_ methods.

This changes the Switch node so that it is implemented directly as a lazy-function, instead of as a normal geometry node which uses `GeoNodeExecParams`. This improves the design of the layered execution api, where different nodes can be implemented at a proper different abstraction level. The simplest kinds of nodes are implemented as multi-function, then there is `GeoNodeExecParams` and more specialized nodes are implemented as lazy-function. The switch node is special in the sense that it currently needs extra behavior in the lazy-function graph generation anyway. `GeoNodeExecParams` can be simplified as well, because the Switch node was the only one that used the `lazy_` methods.
Jacques Lucke added 5 commits 2023-03-12 18:40:48 +01:00
Jacques Lucke requested review from Lukas Tönne 2023-03-12 18:46:24 +01:00
Jacques Lucke requested review from Hans Goudey 2023-03-12 18:46:24 +01:00

This PR removes the ability to make ALL other nodes lazy, according to some design, partially described in the RP description: #105264.
All nodes can be lazy and this would be very useful as part of the desire for geometry nodes to be much more scalable through assets. This would imply the need to reduce the overhead on the abstraction of node groups, not all of the results of which can always be used.

This PR removes the ability to make ALL other nodes lazy, according to some design, partially described in the RP description: https://projects.blender.org/blender/blender/pulls/105264. All nodes can be lazy and this would be very useful as part of the desire for geometry nodes to be much more scalable through assets. This would imply the need to reduce the overhead on the abstraction of node groups, not all of the results of which can always be used.
Author
Member

It does not remove the ability to add lazy behavior to nodes, it does change how it would be done though. It might be ok to add a different API for this back at some point, but I don't like the current approach. There shouldn't be a need for a per node type boolean to indicate that it supports lazyness. Maybe that can somehow be integrated with node declarations.

It does not remove the ability to add lazy behavior to nodes, it does change how it would be done though. It might be ok to add a different API for this back at some point, but I don't like the current approach. There shouldn't be a need for a per node type boolean to indicate that it supports lazyness. Maybe that can somehow be integrated with node declarations.
Hans Goudey approved these changes 2023-03-13 14:44:11 +01:00
Hans Goudey left a comment
Member

Looks good to me. The node is easier to understand now, and much less annoying boilerplate. I share a bit of the concern about how these lazy features can be implemented in most other nodes now, but the big picture you described seems fine.

Looks good to me. The node is easier to understand now, and much less annoying boilerplate. I share a bit of the concern about how these lazy features can be implemented in most other nodes now, but the big picture you described seems fine.
@ -221,6 +221,10 @@ class GeometryNodesLazyFunctionLogger : public fn::lazy_function::GraphExecutor:
const lf::Context &context) const override;
};
namespace node_geo_switch_cc {
Member

I'm not sure how I feel about these unity build namespaces leaking to separate files. Maybe the public function from that file should be in the blender::nodes namespace like other cases. Or blender::nodes::geometry? (though that could be done elsewhere too)

I'm not sure how I feel about these unity build namespaces leaking to separate files. Maybe the public function from that file should be in the `blender::nodes` namespace like other cases. Or `blender::nodes::geometry`? (though that could be done elsewhere too)
@ -208,3 +185,1 @@
return;
}
bool switch_value = params.get_input<bool>("Switch_001");
static const int false_input_index = 1;
Member

static constexpr?

`static constexpr`?
@ -219,0 +193,4 @@
params.set_input_unused(input_to_ignore);
void *value_to_forward = params.try_get_input_data_ptr_or_request(input_to_forward);
if (value_to_forward == nullptr) {
/* True again when the value is available. */
Member

True again -> Try again?

`True again` -> `Try again`?
@ -287,3 +225,1 @@
default:
BLI_assert_unreachable();
break;
GField output_field{std::make_shared<FieldOperation>(
Member

How about this?

    GField output_field{FieldOperation::Create(
        switch_multi_function,
        {std::move(condition), std::move(false_field), std::move(true_field)})};
How about this? ```c++ GField output_field{FieldOperation::Create( switch_multi_function, {std::move(condition), std::move(false_field), std::move(true_field)})}; ```
Lukas Tönne approved these changes 2023-03-14 10:30:22 +01:00
Lukas Tönne left a comment
Member

Looks good, i have nothing substantial to add. A better API for lazy functions that doesn't rely on logic in GeometryNodesLazyFunctionGraphBuilder would be nice, but can be a separate task.

Looks good, i have nothing substantial to add. A better API for lazy functions that doesn't rely on logic in `GeometryNodesLazyFunctionGraphBuilder` would be nice, but can be a separate task.
Jacques Lucke added 4 commits 2023-03-14 14:04:22 +01:00
Jacques Lucke merged commit 258678916f into main 2023-03-14 14:09:39 +01:00
Jacques Lucke deleted branch switch-node-separate-api 2023-03-14 14:09:39 +01:00
Sign in to join this conversation.
No reviewers
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
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#105696
No description provided.