Revert "Cycles: Cleanup: Don't use return on function returning void"
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Jun 2018 09:57:57 +0000 (11:57 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Jun 2018 09:57:57 +0000 (11:57 +0200)
Not sure why exactly it is called a cleanup, the code was much more clear
and robust against possible missing return statements which are MANDATORY.

Missing return statement will:

- Cause two different BVH traversals to be run.

  Not is happening currently, but if more BVH layouts are added, it will
  become a problem.

- It is already causing assert() statements to fail, since functions are
  no longer returning when they are supposed to.

If there is any measurable reason to keep this change, let me know.
Otherwise just stick to reliable/tested/robust code.

This reverts commit ba65f7093b39a8e5f1fb869cbc347fb810a05ab9.

intern/cycles/kernel/bvh/bvh.h
intern/cycles/kernel/bvh/bvh_local.h

index c0a5bb434eafdb83368d4534b936adad55e55f24..d3e0b25a20063958611472211ee4f5d170342df6 100644 (file)
@@ -212,21 +212,20 @@ ccl_device_intersect void scene_intersect_local(KernelGlobals *kg,
 {
 #ifdef __OBJECT_MOTION__
        if(kernel_data.bvh.have_motion) {
-               bvh_intersect_local_motion(kg,
-                                          &ray,
-                                          local_isect,
-                                          local_object,
-                                          lcg_state,
-                                          max_hits);
-               return;
+               return bvh_intersect_local_motion(kg,
+                                                 &ray,
+                                                 local_isect,
+                                                 local_object,
+                                                 lcg_state,
+                                                 max_hits);
        }
 #endif /* __OBJECT_MOTION__ */
-       bvh_intersect_local(kg,
-                           &ray,
-                           local_isect,
-                           local_object,
-                           lcg_state,
-                           max_hits);
+       return bvh_intersect_local(kg,
+                                   &ray,
+                                   local_isect,
+                                   local_object,
+                                   lcg_state,
+                                   max_hits);
 }
 #endif
 
index 605d4166819ffbc104a735bb8e6319905572395c..9292cc76a5cc81030e73d04cdf3ba6344bd2f265 100644 (file)
@@ -246,22 +246,20 @@ ccl_device_inline void BVH_FUNCTION_NAME(KernelGlobals *kg,
        switch(kernel_data.bvh.bvh_layout) {
 #ifdef __QBVH__
                case BVH_LAYOUT_BVH4:
-                       BVH_FUNCTION_FULL_NAME(QBVH)(kg,
-                                                    ray,
-                                                    local_isect,
-                                                    local_object,
-                                                    lcg_state,
-                                                    max_hits);
-                       break;
+                       return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
+                                                           ray,
+                                                           local_isect,
+                                                           local_object,
+                                                           lcg_state,
+                                                           max_hits);
 #endif
                case BVH_LAYOUT_BVH2:
-                       BVH_FUNCTION_FULL_NAME(BVH)(kg,
-                                                   ray,
-                                                   local_isect,
-                                                   local_object,
-                                                   lcg_state,
-                                                   max_hits);
-                       break;
+                       return BVH_FUNCTION_FULL_NAME(BVH)(kg,
+                                                          ray,
+                                                          local_isect,
+                                                          local_object,
+                                                          lcg_state,
+                                                          max_hits);
        }
        kernel_assert(!"Should not happen");
 }