diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-27 11:55:48 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-27 11:55:48 +0300 |
commit | 7dae62cde0e4159c6a952655da3ae87b44f5c64e (patch) | |
tree | 484802c3b2f487087276573823f1a30096ef1086 /intern/cycles/kernel/geom | |
parent | c3eb7c4e9d05e96ec9e858b398640b0c8c9692ea (diff) |
Cycles: Simplify code around debug stats in BVH traversing
Diffstat (limited to 'intern/cycles/kernel/geom')
-rw-r--r-- | intern/cycles/kernel/geom/geom_bvh.h | 22 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_bvh_traversal.h | 26 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_qbvh_traversal.h | 25 |
3 files changed, 34 insertions, 39 deletions
diff --git a/intern/cycles/kernel/geom/geom_bvh.h b/intern/cycles/kernel/geom/geom_bvh.h index 9eadc97386c..d0eedd3396a 100644 --- a/intern/cycles/kernel/geom/geom_bvh.h +++ b/intern/cycles/kernel/geom/geom_bvh.h @@ -48,6 +48,28 @@ CCL_NAMESPACE_BEGIN #define BVH_FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0) +/* Debugging heleprs */ +#ifdef __KERNEL_DEBUG__ +# define BVH_DEBUG_INIT() \ + do { \ + isect->num_traversal_steps = 0; \ + isect->num_traversed_instances = 0; \ + } while(0) +# define BVH_DEBUG_NEXT_STEP() \ + do { \ + ++isect->num_traversal_steps; \ + } while(0) +# define BVH_DEBUG_NEXT_INSTANCE() \ + do { \ + ++isect->num_traversed_instances; \ + } while(0) +#else /* __KERNEL_DEBUG__ */ +# define BVH_DEBUG_INIT() +# define BVH_DEBUG_NEXT_STEP() +# define BVH_DEBUG_NEXT_INSTANCE() +#endif /* __KERNEL_DEBUG__ */ + + /* Common QBVH functions. */ #ifdef __QBVH__ # include "geom_qbvh.h" diff --git a/intern/cycles/kernel/geom/geom_bvh_traversal.h b/intern/cycles/kernel/geom/geom_bvh_traversal.h index 8560612addc..ae919ef3f86 100644 --- a/intern/cycles/kernel/geom/geom_bvh_traversal.h +++ b/intern/cycles/kernel/geom/geom_bvh_traversal.h @@ -74,10 +74,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, 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(); @@ -241,10 +238,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, --stackPtr; } } - -#if defined(__KERNEL_DEBUG__) - isect->num_traversal_steps++; -#endif + BVH_DEBUG_NEXT_STEP(); } /* 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++) { -#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 */ @@ -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 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 */ @@ -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++) { -# 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) @@ -364,9 +352,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, nodeAddr = kernel_tex_fetch(__object_node, object); -# if defined(__KERNEL_DEBUG__) - isect->num_traversed_instances++; -# endif + BVH_DEBUG_NEXT_INSTANCE(); } } #endif /* FEATURE(BVH_INSTANCING) */ diff --git a/intern/cycles/kernel/geom/geom_qbvh_traversal.h b/intern/cycles/kernel/geom/geom_qbvh_traversal.h index ce3bbbdf957..738d08ac6fc 100644 --- a/intern/cycles/kernel/geom/geom_qbvh_traversal.h +++ b/intern/cycles/kernel/geom/geom_qbvh_traversal.h @@ -78,10 +78,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, 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(); ssef tnear(0.0f), tfar(ray->t); sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z)); @@ -120,9 +117,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, int traverseChild; ssef dist; -#if defined(__KERNEL_DEBUG__) - isect->num_traversal_steps++; -#endif + BVH_DEBUG_NEXT_STEP(); #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) if(difl != 0.0f) { @@ -295,9 +290,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, 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)) { tfar = ssef(isect->t); @@ -311,9 +304,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, #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)) { tfar = ssef(isect->t); @@ -329,9 +320,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, 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) @@ -381,9 +370,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, nodeAddr = kernel_tex_fetch(__object_node, object); -# if defined(__KERNEL_DEBUG__) - isect->num_traversed_instances++; -# endif + BVH_DEBUG_NEXT_INSTANCE(); } } #endif /* FEATURE(BVH_INSTANCING) */ |