Cycles: build Light Tree in parallel #105862
No reviewers
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105862
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "weizhen/blender:parallel_light_tree"
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?
Push a task to
TaskPool
when more thanMIN_PRIMS_PER_THREAD
primitives are to be processed. The nodes are rearranged in a depth-first order when copied to the device.Tested with the scene in #105550 on an Apple M1 Ultra (20 cores), about 11x speedup.
Alaska referenced this pull request2023-03-19 00:53:25 +01:00
26d66945c6
to8bd9a5bf0a
8bd9a5bf0a
to66b46eee66
@blender-bot build
66b46eee66
to1b9d56ce9c
Build again with
MIN_PRIMS_PER_THREAD
set toINT_MAX
to test the parallel build.@blender-bot build
1b9d56ce9c
to2539258099
WIP: Cycles: build Light Tree in parallelto Cycles: build Light Tree in parallelThis looks generally fine, just some comments on implementation details.
Eventually we can also parallelize the loops in nodes with many prims. I suggest to add that as a separate bullet point in #77889 and make a comment in the code.
@ -235,3 +230,1 @@
int LightTree::recursive_build(
int start, int end, vector<LightTreePrimitive> &prims, uint bit_trail, int depth)
template<Child child>
Is there a reason this is a template argument instead of a regular function argument?
It's only used for
parent->children[child]
, not worth specializing the function for as far as I can see.@ -53,2 +54,4 @@
*/
/* Left or right child of an inner node. */
enum Child {
This name is too generic to put in the global Cycles namespace. Should be either defined inside the
LightTree
class, or namedLightTreeChild
.@ -143,0 +160,4 @@
const uint &bit_trial)
{
num_nodes++;
return new LightTreeNode(bbox, bcone, energy, bit_trial);
We try to avoid
new
anddelete
in new code to avoid potential memory allocation bugs. Insteadunique_ptr
andmake_unique
can be used.@ -235,3 +230,1 @@
int LightTree::recursive_build(
int start, int end, vector<LightTreePrimitive> &prims, uint bit_trail, int depth)
template<Child child>
It's also used for
recursive_build<left>(current_node, start, middle, prims, bit_trail, depth + 1);
, I think it looks better thanrecursive_build(0, current_node, start, middle, prims, bit_trail, depth + 1);
I tried to parallelize that too, but I saw almost no performance improvement.
After this pull request is merged, I'll build another one upon it that computes the bounding box (and so on) of a node by summing up the buckets, then it should be fine.
@ -235,3 +230,1 @@
int LightTree::recursive_build(
int start, int end, vector<LightTreePrimitive> &prims, uint bit_trail, int depth)
template<Child child>
I think this would look ok too?
Generally there should be a performance reason for using templates like this. Not a big deal for any individual function, but still would rather not do it here.
Child
enum intoLightTree
class 86cb473f11