[Bf-blender-cvs] [517533fa46e] soc-2022-many-lights-sampling: use a single struct to represent light tree nodes on device

Jebbly noreply at git.blender.org
Fri Jun 10 16:33:00 CEST 2022


Commit: 517533fa46ebc7622c6e68c8966c3090c264366b
Author: Jebbly
Date:   Fri Jun 10 09:58:46 2022 -0400
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB517533fa46ebc7622c6e68c8966c3090c264366b

use a single struct to represent light tree nodes on device

===================================================================

M	intern/cycles/kernel/types.h
M	intern/cycles/scene/scene.cpp
M	intern/cycles/scene/scene.h

===================================================================

diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h
index 9f4118feb8e..fa36fd0ab9c 100644
--- a/intern/cycles/kernel/types.h
+++ b/intern/cycles/kernel/types.h
@@ -1489,6 +1489,33 @@ typedef struct KernelLightDistribution {
 } KernelLightDistribution;
 static_assert_align(KernelLightDistribution, 16);
 
+typedef struct KernelLightTreeNode {
+  /* Bounding box. */
+  float bounding_box_min[3];
+  float bounding_box_max[3];
+
+  /* Bounding cone. */
+  float bounding_cone_axis[3];
+  float theta_o;
+  float theta_e;
+
+  /* Energy. */
+  float energy;
+
+  /* If this is 0 or less, we're at a leaf node
+   * and the negative value indexes into the first child of the light array.
+   * Otherwise, it's an index to the node's second child. */
+  int child_index;
+  union {
+    int num_prims; /* leaf nodes need to know the number of primitives stored. */
+    float energy_variance; /* interior nodes use the energy variance for the splitting heuristic. */
+  };
+
+  /* Padding. */
+  int pad1, pad2;
+} KernelLightTreeNode;
+static_assert_align(KernelLightTreeNode, 16);
+
 typedef struct KernelParticle {
   int index;
   float age;
diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp
index 27ded40fa7a..40aa350ccfa 100644
--- a/intern/cycles/scene/scene.cpp
+++ b/intern/cycles/scene/scene.cpp
@@ -71,8 +71,7 @@ DeviceScene::DeviceScene(Device *device)
       lights(device, "__lights", MEM_GLOBAL),
       light_background_marginal_cdf(device, "__light_background_marginal_cdf", MEM_GLOBAL),
       light_background_conditional_cdf(device, "__light_background_conditional_cdf", MEM_GLOBAL),
-      light_tree_interior_nodes(device, "__light_tree_interior_nodes", MEM_GLOBAL),
-      light_tree_leaf_nodes(device, "__light_tree_leaf_nodes", MEM_GLOBAL),
+      light_tree_nodes(device, "__light_tree_nodes", MEM_GLOBAL),
       particles(device, "__particles", MEM_GLOBAL),
       svm_nodes(device, "__svm_nodes", MEM_GLOBAL),
       shaders(device, "__shaders", MEM_GLOBAL),
diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h
index c3a689c2c19..c9365f7f07b 100644
--- a/intern/cycles/scene/scene.h
+++ b/intern/cycles/scene/scene.h
@@ -110,8 +110,9 @@ class DeviceScene {
   device_vector<KernelLight> lights;
   device_vector<float2> light_background_marginal_cdf;
   device_vector<float2> light_background_conditional_cdf;
-  device_vector<float4> light_tree_interior_nodes;
-  device_vector<float4> light_tree_leaf_nodes;
+
+  /* light tree */
+  device_vector<KernelLightTreeNode> light_tree_nodes;
 
   /* particles */
   device_vector<KernelParticle> particles;



More information about the Bf-blender-cvs mailing list