Geometry Nodes: Face Group Boundaries node speedup #115138
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#115138
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:speedup_face_group_boundaries"
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?
Parallel version of function to compute boundary edges.
New multithreaded algorithm is used concept from #112415, without creating jagged array of face indices though.
Array of indices is store last face for each edge. In case new face have different Group ID, face index
will be come to invalid state and will be bypassed in all next checks.
Speed improvement for attached example file is listed in table:
71920 ns
97400 ns
1.27 ms
1.17 ms
79.37 ms
23.16 ms
520.31 ms
142.21 ms
Nice numbers. It also might be worth considering using the edge to corner topology map?
I also thinking about that. I haven't test this. But this have some similar ideas: Here is used the same atomic list of last indices as in #112415. But here coping of indices in to segmented span is not necessary due to we can check is all elements have the same group id during list building.
I'll still probably test a version using the topology map, but this is looking reasonable now.
@ -57,3 +58,1 @@
if (edge_face_set[edge] != face_set[i]) {
/* This edge is connected to two faces on different face sets. */
boundary[edge] = true;
Array<int> previos_face(mesh.totedge, no_face_yet);
Using
Array<std::atomic<int>>
probably makes this code a bit nicer, worth looking into?Will check this now. Mainly i try to avoid
std::atomic<T>
due to that is not realT
instance, so anyT
->atomic<T>
conversions have to be done as copy... but in in pr case, not sure if there is any problem. I found that size ofstd::atomic<T>
can be the same asT
, but that is not guaranteed, but this is not really important for that case too i hope....@ -60,0 +62,4 @@
const static constexpr int no_face_yet = -1;
const static constexpr int no_more_face = -2;
threading::parallel_for(edge_states.index_range(), 4096, [&](const IndexRange range) {
Does this work?
I guess maybe not. Ideally this would compile down to a
memset
. If it doesn't, maybe worth using the old version. A bit tricky...There is no copy-constructor...
Also about
memset
(just found) https://devblogs.microsoft.com/oldnewthing/20180328-00/?p=98365My mesure show the same speed, so not sure if this have any other problems unlike this manual initialization...
Tested this with topology maps like I mentioned:
20x20x20
100x100x100
500x500x500
1000x1000x1000
Unless the topology maps are already cached (edge to face maps currently aren't), the approach in this PR is much faster. So I think it's best to go with this for now. One reason it's better is probably because we end up reading from the face group ID varray much less. Nice job :)
I left some style comments though.
@ -58,2 +55,2 @@
/* This edge is connected to two faces on different face sets. */
boundary[edge] = true;
Array<std::atomic_int> edge_states(mesh.totedge);
Array<std::atomic<int>>
unless you had a reason to do it this way.@ -60,0 +55,4 @@
Array<std::atomic_int> edge_states(mesh.totedge);
/* State is index of face or one of invalid values: */
const static constexpr int no_face_yet = -1;
A simple
constexpr int
seems fine to meThis requered to use this as case in
switch
statment.Ah, both
const
andstatic
? I thoughtconst
was redundant withconstexpr
anywayWell,
static
at least, maybeconst
can be omited..@ -60,0 +56,4 @@
Array<std::atomic_int> edge_states(mesh.totedge);
/* State is index of face or one of invalid values: */
const static constexpr int no_face_yet = -1;
const static constexpr int no_more_face = -2;
Maybe
no_more_face
->is_boundary
@ -60,0 +64,4 @@
}
});
const GroupedSpan<int> face_edges(mesh.face_offsets(), mesh.corner_edges());
I usually reserve
face_edges
for the variable of the edge indices of a specific face. Keepingcorner_edges.slice(faces[face_i])
inline for consistency seems better to me. Though I don't have a strong opinion.@ -60,0 +71,4 @@
for (const int edge_i : face_edges[face_i]) {
std::atomic_int &edge_state = edge_states[edge_i];
while (true) {
int edge_state_v = edge_state.load(std::memory_order_relaxed);
What does
_v
mean?edge_state_value
@blender-bot build
@blender-bot build