Cycles: Simplify code around debug stats in BVH traversing
[blender.git] / intern / cycles / kernel / geom / geom_bvh_traversal.h
index 8560612addcc4137cbb150e153a5182275ae281b..ae919ef3f869b08914d9372d9def78de032510a4 100644 (file)
@@ -74,10 +74,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        isect->prim = PRIM_NONE;
        isect->object = OBJECT_NONE;
 
        isect->prim = PRIM_NONE;
        isect->object = OBJECT_NONE;
 
-#if defined(__KERNEL_DEBUG__)
-       isect->num_traversal_steps = 0;
-       isect->num_traversed_instances = 0;
-#endif
+       BVH_DEBUG_INIT();
 
 #if defined(__KERNEL_SSE2__)
        const shuffle_swap_t shuf_identity = shuffle_swap_identity();
 
 #if defined(__KERNEL_SSE2__)
        const shuffle_swap_t shuf_identity = shuffle_swap_identity();
@@ -241,10 +238,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                --stackPtr;
                                        }
                                }
                                                --stackPtr;
                                        }
                                }
-
-#if defined(__KERNEL_DEBUG__)
-                               isect->num_traversal_steps++;
-#endif
+                               BVH_DEBUG_NEXT_STEP();
                        }
 
                        /* if node is leaf, fetch triangle list */
                        }
 
                        /* if node is leaf, fetch triangle list */
@@ -266,9 +260,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        switch(type & PRIMITIVE_ALL) {
                                                case PRIMITIVE_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
                                        switch(type & PRIMITIVE_ALL) {
                                                case PRIMITIVE_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(triangle_intersect(kg, &isect_precalc, isect, P, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(triangle_intersect(kg, &isect_precalc, isect, P, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
@@ -287,9 +279,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 #if BVH_FEATURE(BVH_MOTION)
                                                case PRIMITIVE_MOTION_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
 #if BVH_FEATURE(BVH_MOTION)
                                                case PRIMITIVE_MOTION_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
@@ -310,9 +300,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                case PRIMITIVE_CURVE:
                                                case PRIMITIVE_MOTION_CURVE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
                                                case PRIMITIVE_CURVE:
                                                case PRIMITIVE_MOTION_CURVE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                bool hit;
                                                                if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                bool hit;
                                                                if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
@@ -364,9 +352,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
                                        nodeAddr = kernel_tex_fetch(__object_node, object);
 
 
                                        nodeAddr = kernel_tex_fetch(__object_node, object);
 
-#  if defined(__KERNEL_DEBUG__)
-                                       isect->num_traversed_instances++;
-#  endif
+                                       BVH_DEBUG_NEXT_INSTANCE();
                                }
                        }
 #endif  /* FEATURE(BVH_INSTANCING) */
                                }
                        }
 #endif  /* FEATURE(BVH_INSTANCING) */