[Bf-blender-cvs] [b1837d5f69b] gsoc-2018-many-light-sampling: Fix CUDA build for many light sampling, still fails when running.

Brecht Van Lommel noreply at git.blender.org
Mon Jul 30 12:47:50 CEST 2018


Commit: b1837d5f69b1b2a8ec931c5a7a73464315d639b0
Author: Brecht Van Lommel
Date:   Sun Jul 29 16:24:27 2018 +0200
Branches: gsoc-2018-many-light-sampling
https://developer.blender.org/rBb1837d5f69b1b2a8ec931c5a7a73464315d639b0

Fix CUDA build for many light sampling, still fails when running.

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

M	intern/cycles/kernel/kernel_light.h
M	intern/cycles/kernel/kernel_path_branched.h
M	intern/cycles/kernel/kernel_path_surface.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/light_tree.cpp

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

diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index abad0886727..5a2facaa454 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -1146,12 +1146,12 @@ ccl_device float calc_light_importance(KernelGlobals *kg, float3 P, float3 N,
 	const float4 node1 = kernel_tex_fetch(__light_tree_leaf_emitters, offset + 1);
 	const float4 node2 = kernel_tex_fetch(__light_tree_leaf_emitters, offset + 2);
 
-	const float3 bboxMin  = make_float3( node0[0], node0[1], node0[2]);
-	const float3 bboxMax  = make_float3( node0[3], node1[0], node1[1]);
-	const float  theta_o  = node1[2];
-	const float  theta_e  = node1[3];
-	const float3 axis     = make_float3(node2[0], node2[1], node2[2]);
-	const float  energy   = node2[3];
+	const float3 bboxMin  = make_float3(node0.x, node0.y, node0.z);
+	const float3 bboxMax  = make_float3(node0.w, node1.x, node1.y);
+	const float  theta_o  = node1.z;
+	const float  theta_e  = node1.w;
+	const float3 axis     = make_float3(node2.x, node2.y, node2.z);
+	const float  energy   = node2.w;
 	const float3 centroid = 0.5f*(bboxMax + bboxMin);
 
 	return calc_importance(kg, P, N, bboxMax, theta_o, theta_e, axis, energy,
@@ -1165,12 +1165,12 @@ ccl_device float calc_node_importance(KernelGlobals *kg, float3 P, float3 N, int
 	const float4 node2 = kernel_tex_fetch(__light_tree_nodes, node_offset + 2);
 	const float4 node3 = kernel_tex_fetch(__light_tree_nodes, node_offset + 3);
 
-	const float  energy   = node0[0];
-	const float3 bboxMin  = make_float3( node1[0], node1[1], node1[2]);
-	const float3 bboxMax  = make_float3( node1[3], node2[0], node2[1]);
-	const float  theta_o  = node2[2];
-	const float  theta_e  = node2[3];
-	const float3 axis     = make_float3(node3[0], node3[1], node3[2]);
+	const float  energy   = node0.x;
+	const float3 bboxMin  = make_float3(node1.x, node1.y, node1.z);
+	const float3 bboxMax  = make_float3(node1.w, node2.x, node2.y);
+	const float  theta_o  = node2.z;
+	const float  theta_e  = node2.w;
+	const float3 axis     = make_float3(node3.x, node3.y, node3.z);
 	const float3 centroid = 0.5f*(bboxMax + bboxMin);
 
 	return calc_importance(kg, P, N, bboxMax, theta_o, theta_e, axis, energy,
@@ -1182,9 +1182,9 @@ ccl_device void update_parent_node(KernelGlobals *kg, int node_offset,
                                    int *num_emitters)
 {
 	float4 node        = kernel_tex_fetch(__light_tree_nodes, node_offset);
-	(*childOffset)     = __float_as_int(node[1]);
-	(*distribution_id) = __float_as_int(node[2]);
-	(*num_emitters)    = __float_as_int(node[3]);
+	(*childOffset)     = __float_as_int(node.y);
+	(*distribution_id) = __float_as_int(node.z);
+	(*num_emitters)    = __float_as_int(node.w);
 }
 
 /* picks one of the distant lights and computes the probability of picking it */
@@ -1321,8 +1321,7 @@ ccl_device int triangle_to_distribution(KernelGlobals *kg, int triangle_id)
 			count = step;
 	}
 
-	int triangle = kernel_tex_fetch(__triangle_to_distribution, first*2);
-	kernel_assert(triangle == triangle_id);
+	kernel_assert(kernel_tex_fetch(__triangle_to_distribution, first*2) == triangle_id);
 
 	return kernel_tex_fetch(__triangle_to_distribution, first*2+1);
 }
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
index 84faac89066..a728aa32c5e 100644
--- a/intern/cycles/kernel/kernel_path_branched.h
+++ b/intern/cycles/kernel/kernel_path_branched.h
@@ -451,7 +451,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
 	PathState state;
 	path_state_init(kg, emission_sd, &state, rng_hash, sample, &ray);
 
-	float3 MIS_N = make_float3(0.0f);
+	float3 MIS_N = make_float3(0.0f, 0.0f, 0.0f);
 	/* Main Loop
 	 * Here we only handle transparency intersections from the camera ray.
 	 * Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index 7a42486767c..46e6259d393 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "util/util_logging.h"
+//#include "util/util_logging.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -59,8 +59,8 @@ ccl_device bool split(KernelGlobals *kg, float3 P, int node_offset)
 	/* extract bounding box of cluster */
 	const float4 node1   = kernel_tex_fetch(__light_tree_nodes, node_offset + 1);
 	const float4 node2   = kernel_tex_fetch(__light_tree_nodes, node_offset + 2);
-	const float3 bboxMin = make_float3( node1[0], node1[1], node1[2]);
-	const float3 bboxMax = make_float3( node1[3], node2[0], node2[1]);
+	const float3 bboxMin = make_float3(node1.x, node1.y, node1.z);
+	const float3 bboxMax = make_float3(node1.w, node2.x, node2.y);
 
 	/* if P is inside bounding sphere then split */
 	const float3 centroid = 0.5f * (bboxMax + bboxMin);
@@ -90,9 +90,9 @@ ccl_device bool split(KernelGlobals *kg, float3 P, int node_offset)
 	/* eq. 10 */
 	const float4 node0   = kernel_tex_fetch(__light_tree_nodes, node_offset    );
 	const float4 node3   = kernel_tex_fetch(__light_tree_nodes, node_offset + 3);
-	const double energy       = (double)node0[0];
-	const double e_variance   = (double)node3[3];
-	const double num_emitters = (double)__float_as_int(node0[3]);
+	const double energy       = (double)node0.x;
+	const double e_variance   = (double)node3.w;
+	const double num_emitters = (double)__float_as_int(node0.w);
 
 	const double num_emitters_squared = num_emitters * num_emitters;
 	const double e_mean = energy / num_emitters;
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index db48318dc44..67f530a96b8 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1248,19 +1248,19 @@ typedef struct KernelFilm {
 	int pass_glossy_color;
 	int pass_transmission_color;
 	int pass_subsurface_color;
-	
+
 	int pass_diffuse_indirect;
 	int pass_glossy_indirect;
 	int pass_transmission_indirect;
 	int pass_subsurface_indirect;
 	int pass_volume_indirect;
-	
+
 	int pass_diffuse_direct;
 	int pass_glossy_direct;
 	int pass_transmission_direct;
 	int pass_subsurface_direct;
 	int pass_volume_direct;
-	
+
 	int pass_emission;
 	int pass_background;
 	int pass_ao;
@@ -1529,7 +1529,7 @@ typedef struct KernelLightDistribution {
 	float area;
 	float totarea;
 	int prim;
-	float pad1,pad2,pad3;
+	float pad1, pad2, pad3;
 	union {
 		struct {
 			int shader_flag;
@@ -1692,4 +1692,3 @@ typedef struct WorkTile {
 CCL_NAMESPACE_END
 
 #endif /*  __KERNEL_TYPES_H__ */
-
diff --git a/intern/cycles/render/light_tree.cpp b/intern/cycles/render/light_tree.cpp
index b9c4821e019..ad53b84f360 100644
--- a/intern/cycles/render/light_tree.cpp
+++ b/intern/cycles/render/light_tree.cpp
@@ -525,7 +525,7 @@ BVHBuildNode* LightTree::recursive_build(const unsigned int start,
 			split_saoh(centroidBbox, buildData, start, end, nBuckets,
 			           (float)node_energy, node_M_Omega, node_bbox,
 			           min_cost, min_dim, min_bucket);
-			assert(total_min_dim != -1);
+			assert(min_dim != -1);
 
 			int mid = 0;
 			if (num_emitters > maxPrimsInNode || min_cost < (float)node_energy){



More information about the Bf-blender-cvs mailing list