[Bf-blender-cvs] [f79f3867314] master: Code refactor: rename subsurface to local traversal, for reuse.

Brecht Van Lommel noreply at git.blender.org
Wed Nov 8 00:02:43 CET 2017


Commit: f79f38673145c716f9a693084b0bc4c4873e66c1
Author: Brecht Van Lommel
Date:   Mon Oct 30 20:25:08 2017 +0100
Branches: master
https://developer.blender.org/rBf79f38673145c716f9a693084b0bc4c4873e66c1

Code refactor: rename subsurface to local traversal, for reuse.

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

M	intern/cycles/device/device.h
M	intern/cycles/kernel/CMakeLists.txt
M	intern/cycles/kernel/bvh/bvh.h
R076	intern/cycles/kernel/bvh/bvh_subsurface.h	intern/cycles/kernel/bvh/bvh_local.h
R082	intern/cycles/kernel/bvh/qbvh_subsurface.h	intern/cycles/kernel/bvh/qbvh_local.h
M	intern/cycles/kernel/geom/geom_motion_triangle_intersect.h
M	intern/cycles/kernel/geom/geom_motion_triangle_shader.h
M	intern/cycles/kernel/geom/geom_triangle_intersect.h
M	intern/cycles/kernel/kernel_path_branched.h
M	intern/cycles/kernel/kernel_path_subsurface.h
M	intern/cycles/kernel/kernel_shader.h
M	intern/cycles/kernel/kernel_subsurface.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/kernel/split/kernel_split_data_types.h
M	intern/cycles/kernel/split/kernel_subsurface_scatter.h
M	intern/cycles/render/graph.h
M	intern/cycles/render/shader.cpp

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

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 4f78b9e82a4..6bf3bbe6c25 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -139,6 +139,9 @@ public:
 	/* Denoising features. */
 	bool use_denoising;
 
+	/* Use raytracing in shaders. */
+	bool use_shader_raytrace;
+
 	DeviceRequestedFeatures()
 	{
 		/* TODO(sergey): Find more meaningful defaults. */
@@ -158,6 +161,7 @@ public:
 		use_shadow_tricks = false;
 		use_principled = false;
 		use_denoising = false;
+		use_shader_raytrace = false;
 	}
 
 	bool modified(const DeviceRequestedFeatures& requested_features)
@@ -177,7 +181,8 @@ public:
 		         use_transparent == requested_features.use_transparent &&
 		         use_shadow_tricks == requested_features.use_shadow_tricks &&
 		         use_principled == requested_features.use_principled &&
-		         use_denoising == requested_features.use_denoising);
+		         use_denoising == requested_features.use_denoising &&
+		         use_shader_raytrace == requested_features.use_shader_raytrace);
 	}
 
 	/* Convert the requested features structure to a build options,
@@ -230,6 +235,9 @@ public:
 		if(!use_denoising) {
 			build_options += " -D__NO_DENOISING__";
 		}
+		if(!use_shader_raytrace) {
+			build_options += " -D__NO_SHADER_RAYTRACE__";
+		}
 		return build_options;
 	}
 };
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index bd51bc4d371..9d52cef1f2c 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -65,14 +65,14 @@ set(SRC_BVH_HEADERS
 	bvh/bvh.h
 	bvh/bvh_nodes.h
 	bvh/bvh_shadow_all.h
-	bvh/bvh_subsurface.h
+	bvh/bvh_local.h
 	bvh/bvh_traversal.h
 	bvh/bvh_types.h
 	bvh/bvh_volume.h
 	bvh/bvh_volume_all.h
 	bvh/qbvh_nodes.h
 	bvh/qbvh_shadow_all.h
-	bvh/qbvh_subsurface.h
+	bvh/qbvh_local.h
 	bvh/qbvh_traversal.h
 	bvh/qbvh_volume.h
 	bvh/qbvh_volume_all.h
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index cf0c8542d69..d3e0b25a200 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -68,17 +68,17 @@ CCL_NAMESPACE_BEGIN
 
 /* Subsurface scattering BVH traversal */
 
-#if defined(__SUBSURFACE__)
-#  define BVH_FUNCTION_NAME bvh_intersect_subsurface
+#if defined(__BVH_LOCAL__)
+#  define BVH_FUNCTION_NAME bvh_intersect_local
 #  define BVH_FUNCTION_FEATURES BVH_HAIR
-#  include "kernel/bvh/bvh_subsurface.h"
+#  include "kernel/bvh/bvh_local.h"
 
 #  if defined(__OBJECT_MOTION__)
-#    define BVH_FUNCTION_NAME bvh_intersect_subsurface_motion
+#    define BVH_FUNCTION_NAME bvh_intersect_local_motion
 #    define BVH_FUNCTION_FEATURES BVH_MOTION|BVH_HAIR
-#    include "kernel/bvh/bvh_subsurface.h"
+#    include "kernel/bvh/bvh_local.h"
 #  endif
-#endif  /* __SUBSURFACE__ */
+#endif  /* __BVH_LOCAL__ */
 
 /* Volume BVH traversal */
 
@@ -201,31 +201,31 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
 #endif /* __KERNEL_CPU__ */
 }
 
-#ifdef __SUBSURFACE__
+#ifdef __BVH_LOCAL__
 /* Note: ray is passed by value to work around a possible CUDA compiler bug. */
-ccl_device_intersect void scene_intersect_subsurface(KernelGlobals *kg,
-                                                     const Ray ray,
-                                                     SubsurfaceIntersection *ss_isect,
-                                                     int subsurface_object,
-                                                     uint *lcg_state,
-                                                     int max_hits)
+ccl_device_intersect void scene_intersect_local(KernelGlobals *kg,
+                                                const Ray ray,
+                                                LocalIntersection *local_isect,
+                                                int local_object,
+                                                uint *lcg_state,
+                                                int max_hits)
 {
 #ifdef __OBJECT_MOTION__
 	if(kernel_data.bvh.have_motion) {
-		return bvh_intersect_subsurface_motion(kg,
-		                                       &ray,
-		                                       ss_isect,
-		                                       subsurface_object,
-		                                       lcg_state,
-		                                       max_hits);
+		return bvh_intersect_local_motion(kg,
+		                                  &ray,
+		                                  local_isect,
+		                                  local_object,
+		                                  lcg_state,
+		                                  max_hits);
 	}
 #endif /* __OBJECT_MOTION__ */
-	return bvh_intersect_subsurface(kg,
-	                                &ray,
-	                                ss_isect,
-	                                subsurface_object,
-	                                lcg_state,
-	                                max_hits);
+	return bvh_intersect_local(kg,
+	                            &ray,
+	                            local_isect,
+	                            local_object,
+	                            lcg_state,
+	                            max_hits);
 }
 #endif
 
diff --git a/intern/cycles/kernel/bvh/bvh_subsurface.h b/intern/cycles/kernel/bvh/bvh_local.h
similarity index 76%
rename from intern/cycles/kernel/bvh/bvh_subsurface.h
rename to intern/cycles/kernel/bvh/bvh_local.h
index bda7e34907a..12d14428d6d 100644
--- a/intern/cycles/kernel/bvh/bvh_subsurface.h
+++ b/intern/cycles/kernel/bvh/bvh_local.h
@@ -18,7 +18,7 @@
  */
 
 #ifdef __QBVH__
-#  include "kernel/bvh/qbvh_subsurface.h"
+#  include "kernel/bvh/qbvh_local.h"
 #endif
 
 #if BVH_FEATURE(BVH_HAIR)
@@ -27,9 +27,10 @@
 #  define NODE_INTERSECT bvh_aligned_node_intersect
 #endif
 
-/* This is a template BVH traversal function for subsurface scattering, where
- * various features can be enabled/disabled. This way we can compile optimized
- * versions for each case without new features slowing things down.
+/* This is a template BVH traversal function for finding local intersections
+ * around the shading point, for subsurface scattering and bevel. We disable
+ * various features for performance, and for instanced objects avoid traversing
+ * other parts of the scene.
  *
  * BVH_MOTION: motion blur rendering
  *
@@ -42,8 +43,8 @@ ccl_device_inline
 #endif
 void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                  const Ray *ray,
-                                 SubsurfaceIntersection *ss_isect,
-                                 int subsurface_object,
+                                 LocalIntersection *local_isect,
+                                 int local_object,
                                  uint *lcg_state,
                                  int max_hits)
 {
@@ -60,7 +61,7 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
 	/* traversal variables in registers */
 	int stack_ptr = 0;
-	int node_addr = kernel_tex_fetch(__object_node, subsurface_object);
+	int node_addr = kernel_tex_fetch(__object_node, local_object);
 
 	/* ray parameters in registers */
 	float3 P = ray->P;
@@ -69,14 +70,14 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 	int object = OBJECT_NONE;
 	float isect_t = ray->t;
 
-	ss_isect->num_hits = 0;
+	local_isect->num_hits = 0;
 
-	const int object_flag = kernel_tex_fetch(__object_flag, subsurface_object);
+	const int object_flag = kernel_tex_fetch(__object_flag, local_object);
 	if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
 #if BVH_FEATURE(BVH_MOTION)
 		Transform ob_itfm;
 		isect_t = bvh_instance_motion_push(kg,
-		                                   subsurface_object,
+		                                   local_object,
 		                                   ray,
 		                                   &P,
 		                                   &dir,
@@ -84,9 +85,9 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 		                                   isect_t,
 		                                   &ob_itfm);
 #else
-		isect_t = bvh_instance_push(kg, subsurface_object, ray, &P, &dir, &idir, isect_t);
+		isect_t = bvh_instance_push(kg, local_object, ray, &P, &dir, &idir, isect_t);
 #endif
-		object = subsurface_object;
+		object = local_object;
 	}
 
 #if defined(__KERNEL_SSE2__)
@@ -193,15 +194,16 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 						/* intersect ray against primitive */
 						for(; prim_addr < prim_addr2; prim_addr++) {
 							kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-							triangle_intersect_subsurface(kg,
-							                              ss_isect,
-							                              P,
-							                              dir,
-							                              object,
-							                              prim_addr,
-							                              isect_t,
-							                              lcg_state,
-							                              max_hits);
+							triangle_intersect_local(kg,
+							                         local_isect,
+							                         P,
+							                         dir,
+							                         object,
+							                         local_object,
+							                         prim_addr,
+							                         isect_t,
+							                         lcg_state,
+							                         max_hits);
 						}
 						break;
 					}
@@ -210,16 +212,17 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 						/* intersect ray against primitive */
 						for(; prim_addr < prim_addr2; prim_addr++) {
 							kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
-							motion_triangle_intersect_subsurface(kg,
-							                                     ss_isect,
-							                                     P,
-							                                     dir,
-							                                     ray->time,
-							                                     object,
-							                                     prim_addr,
-							                                     isect_t,
-							                                     lcg_state,
-							                                     max_hits);
+							motion_triangle_intersect_local(k

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list