From 53fa389802161e9e4ff6b5e0bfaa61cd4c761be6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jan 2017 13:44:35 +0100 Subject: Cycles: Use dedicated debug passes for traversed nodes and intersection tests This way it's more clear whether some issue is caused by lots of geometry in the node or by lots of "transparent" BVH nodes. --- intern/cycles/kernel/bvh/bvh_traversal.h | 8 ++++---- intern/cycles/kernel/bvh/bvh_types.h | 14 ++++++++++---- intern/cycles/kernel/bvh/qbvh_traversal.h | 8 ++++---- 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'intern/cycles/kernel/bvh') diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h index a0e478e972b..c80a769ffa6 100644 --- a/intern/cycles/kernel/bvh/bvh_traversal.h +++ b/intern/cycles/kernel/bvh/bvh_traversal.h @@ -213,7 +213,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, --stack_ptr; } } - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_NODE(); } /* if node is leaf, fetch triangle list */ @@ -235,7 +235,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, switch(type & PRIMITIVE_ALL) { case PRIMITIVE_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(triangle_intersect(kg, &isect_precalc, @@ -264,7 +264,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) case PRIMITIVE_MOTION_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(motion_triangle_intersect(kg, isect, @@ -296,7 +296,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { diff --git a/intern/cycles/kernel/bvh/bvh_types.h b/intern/cycles/kernel/bvh/bvh_types.h index c3abe2e157d..ead424aaaaf 100644 --- a/intern/cycles/kernel/bvh/bvh_types.h +++ b/intern/cycles/kernel/bvh/bvh_types.h @@ -50,12 +50,17 @@ CCL_NAMESPACE_BEGIN #ifdef __KERNEL_DEBUG__ # define BVH_DEBUG_INIT() \ do { \ - isect->num_traversal_steps = 0; \ + isect->num_traversed_nodes = 0; \ isect->num_traversed_instances = 0; \ + isect->num_intersections = 0; \ } while(0) -# define BVH_DEBUG_NEXT_STEP() \ +# define BVH_DEBUG_NEXT_NODE() \ do { \ - ++isect->num_traversal_steps; \ + ++isect->num_traversed_nodes; \ + } while(0) +# define BVH_DEBUG_NEXT_INTERSECTION() \ + do { \ + ++isect->num_intersections; \ } while(0) # define BVH_DEBUG_NEXT_INSTANCE() \ do { \ @@ -63,7 +68,8 @@ CCL_NAMESPACE_BEGIN } while(0) #else /* __KERNEL_DEBUG__ */ # define BVH_DEBUG_INIT() -# define BVH_DEBUG_NEXT_STEP() +# define BVH_DEBUG_NEXT_NODE() +# define BVH_DEBUG_NEXT_INTERSECTION() # define BVH_DEBUG_NEXT_INSTANCE() #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h index f2d8e558dcc..1846a6073ac 100644 --- a/intern/cycles/kernel/bvh/qbvh_traversal.h +++ b/intern/cycles/kernel/bvh/qbvh_traversal.h @@ -131,7 +131,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, int child_mask; ssef dist; - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_NODE(); #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) if(difl != 0.0f) { @@ -326,7 +326,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, switch(type & PRIMITIVE_ALL) { case PRIMITIVE_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(triangle_intersect(kg, &isect_precalc, @@ -347,7 +347,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) case PRIMITIVE_MOTION_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(motion_triangle_intersect(kg, isect, @@ -371,7 +371,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { -- cgit v1.2.3