Cysles: Avoid having ShaderData on the stack
[blender.git] / intern / cycles / kernel / geom / geom_bvh_subsurface.h
index a093b9b55aace7c9acc70c116f9454c12c5f8986..b9f1a46afb6103431452067cf993a31a513c8b7f 100644 (file)
@@ -30,9 +30,9 @@
  *
  */
 
-ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
+ccl_device void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                             const Ray *ray,
-                                            Intersection *isect_array,
+                                            SubsurfaceIntersection *ss_isect,
                                             int subsurface_object,
                                             uint *lcg_state,
                                             int max_hits)
@@ -60,7 +60,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        int object = OBJECT_NONE;
        float isect_t = ray->t;
 
-       uint num_hits = 0;
+       ss_isect->num_hits = 0;
 
 #if BVH_FEATURE(BVH_MOTION)
        Transform ob_itfm;
@@ -210,7 +210,15 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
                                                                if(tri_object != subsurface_object)
                                                                        continue;
-                                                               triangle_intersect_subsurface(kg, &isect_precalc, isect_array, P, object, primAddr, isect_t, &num_hits, lcg_state, max_hits);
+                                                               triangle_intersect_subsurface(kg,
+                                                                                             &isect_precalc,
+                                                                                             ss_isect,
+                                                                                             P,
+                                                                                             object,
+                                                                                             primAddr,
+                                                                                             isect_t,
+                                                                                             lcg_state,
+                                                                                             max_hits);
                                                        }
                                                        break;
                                                }
@@ -223,7 +231,16 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
                                                                if(tri_object != subsurface_object)
                                                                        continue;
-                                                               motion_triangle_intersect_subsurface(kg, isect_array, P, dir, ray->time, object, primAddr, isect_t, &num_hits, lcg_state, max_hits);
+                                                               motion_triangle_intersect_subsurface(kg,
+                                                                                                    ss_isect,
+                                                                                                    P,
+                                                                                                    dir,
+                                                                                                    ray->time,
+                                                                                                    object,
+                                                                                                    primAddr,
+                                                                                                    isect_t,
+                                                                                                    lcg_state,
+                                                                                                    max_hits);
                                                        }
                                                        break;
                                                }
@@ -301,13 +318,11 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                }
 #endif  /* FEATURE(BVH_INSTANCING) */
        } while(nodeAddr != ENTRYPOINT_SENTINEL);
-
-       return num_hits;
 }
 
-ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
+ccl_device_inline void BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          const Ray *ray,
-                                         Intersection *isect_array,
+                                         SubsurfaceIntersection *ss_isect,
                                          int subsurface_object,
                                          uint *lcg_state,
                                          int max_hits)
@@ -316,7 +331,7 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
        if(kernel_data.bvh.use_qbvh) {
                return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
                                                    ray,
-                                                   isect_array,
+                                                   ss_isect,
                                                    subsurface_object,
                                                    lcg_state,
                                                    max_hits);
@@ -327,7 +342,7 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
                kernel_assert(kernel_data.bvh.use_qbvh == false);
                return BVH_FUNCTION_FULL_NAME(BVH)(kg,
                                                   ray,
-                                                  isect_array,
+                                                  ss_isect,
                                                   subsurface_object,
                                                   lcg_state,
                                                   max_hits);