Geometry Nodes: Avoid index lookup from index mask #109174
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109174
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:avoid_mask_lookup"
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?
Recent
IndexMask
refactoring introduce log(N) complexity formask[i]
.The greater the fragmentation of the mask, the greater the complexity.
Also, new
IndexMask
implementation have new iterators representedboth real index, and position (
index = mask[position]
).This PR simply replace manual loops by new methods for iterating.
Added
optimized
in some place as slightly speed up.The Attribute Statistic became 5 times better, but due to multithreading (for hight mesh size).
The Extrude (Faces) (Individual) has avarange changed 42 ms -> 36 ms.
Duplicate Elements (for Faces) has avarange changed 220 ms -> 150 ms.
Transform Instances has avarange changed 12 ms ~> 8 ms.
Other nodes have approximately similar improvement numbers.
All tests use Random(50%) selection as mask.
Geometry Nodes: Avoid to lookup index from index maskto Geometry Nodes: Avoid index lookup from index maskYikes, I didn't realize how much of this was left, thanks!
@ -218,3 +218,1 @@
for (const int i : selection.index_range()) {
selected_data[i] = component_data[selection[i]];
}
selection.foreach_index_optimized<int>(GrainSize(2048),
Looks like this is just
array_utils::gather
This is actually
materialize_compressed
)They're the same, but
array_utils::gather
is multithreadedAh, didn't notice this. It's strange that we can't just have one multi-threaded variant.
It makes some sense if multithreading is generally handled outside of the virtual array class I think, it gives the API user a bit better control.
@ -240,3 +229,1 @@
}
}
});
selection.foreach_index(
This looks like it might be
attribute_math::gather_group_to_group
?It seems,
gather_group_to_group
is static right now?What do you think about declaring this into utilities?
Ah good point. Yeah, that could work
Looking at this more closely, I see that the functions are different and not interchangeable.
@ -352,3 +339,1 @@
dst_offsets[i_duplicate] = point_offsets[i_selection].start() +
src_curve_range.size() * i_duplicate;
}
selection.foreach_index_optimized<int>(GrainSize(512), [&](const int index, const int position) {
foreach_index
@ -58,3 +43,1 @@
instance_transform *= math::from_location<float4x4>(-pivot);
instance_transform *= original_transform;
}
selection.foreach_index_optimized<int>(GrainSize(512), [&](const int index) {
foreach_index
There is no nested loops, why?
The matrix math is not exactly cheap
Maybe, but it's not as bad as arbitrary sized data, nested loops, ..., is it?
Would require some measurement to know for sure! But I would guess that the overhead of the non-optimized version wouldn't be significant in this case.
@ -61,0 +44,4 @@
const float3 pivot = pivots[index];
float4x4 &instance_transform = transforms[index];
if (local_spaces[index]) {
index
isn't really a more helpful name thani
, it's just longer.At least it is more convenient for the subsequent search)
The truth is not sure if one character is a good name.
Please just keep the variable name the same, even just to keep the diff smaller
@ -45,3 +39,1 @@
else {
transforms[i].location() += translations[i];
}
selection.foreach_index_optimized<int>(GrainSize(1024), [&](const int index) {
Unless the loop is really very simple, just stick with the non "optimized" version that doesn't generate as much code.
Seems like a pretty simple loop?
Yeah, this one is debatable I guess. Still though, I wonder if it's actually worth it..
@ -82,3 +81,1 @@
counts.materialize_compressed(selection.slice(range),
r_offset_data.as_mutable_span().slice(range));
});
counts.materialize_compressed(selection, r_offset_data.as_mutable_span());
array_utils
here too I think@ -1284,3 +1259,1 @@
else {
connect_data[i_extrude] = bke::attribute_math::mix2(
0.5f, data[orig_edge], data[orig_edge_prev]);
poly_selection.foreach_index_optimized<int>(
How much of a speedup do you get here from using
optimized
?Haven't done any tests yet. But here, most likely, I simply overlooked the nested loop.
@blender-bot build
If you have a chance I'd be interested in seeing some performance comparisons. The changes look good to me.
I added some tests result.
It would be useful to run the test, otherwise, I manually randomly checked the speed in several places. Everything seems to be ready.
@blender-bot build