diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-12 15:44:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-12 15:44:35 +0300 |
commit | 53fa389802161e9e4ff6b5e0bfaa61cd4c761be6 (patch) | |
tree | 485ef4173d970eb3bf10ade844e4d23f4d8dcd56 /intern/cycles | |
parent | 8daf02f134692b21e62649acf2906aed344a70ae (diff) |
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.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/bvh/bvh_traversal.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/bvh/bvh_types.h | 14 | ||||
-rw-r--r-- | intern/cycles/kernel/bvh/qbvh_traversal.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_debug.h | 14 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 3 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 3 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 17 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_scene_intersect.h | 3 | ||||
-rw-r--r-- | intern/cycles/render/buffers.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/render/film.cpp | 10 |
11 files changed, 56 insertions, 33 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index f37e7d17559..04b5c3fa013 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -306,10 +306,12 @@ static PassType get_pass_type(BL::RenderPass& b_pass) case BL::RenderPass::type_DEBUG: { switch(b_pass.debug_type()) { - case BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS: - return PASS_BVH_TRAVERSAL_STEPS; + case BL::RenderPass::debug_type_BVH_TRAVERSED_NODES: + return PASS_BVH_TRAVERSED_NODES; case BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES: return PASS_BVH_TRAVERSED_INSTANCES; + case BL::RenderPass::debug_type_BVH_INTERSECTIONS: + return PASS_BVH_INTERSECTIONS; case BL::RenderPass::debug_type_RAY_BOUNCES: return PASS_RAY_BOUNCES; } 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) { diff --git a/intern/cycles/kernel/kernel_debug.h b/intern/cycles/kernel/kernel_debug.h index 24d6458567e..5647bbae5b5 100644 --- a/intern/cycles/kernel/kernel_debug.h +++ b/intern/cycles/kernel/kernel_debug.h @@ -18,8 +18,9 @@ CCL_NAMESPACE_BEGIN ccl_device_inline void debug_data_init(DebugData *debug_data) { - debug_data->num_bvh_traversal_steps = 0; + debug_data->num_bvh_traversed_nodes = 0; debug_data->num_bvh_traversed_instances = 0; + debug_data->num_bvh_intersections = 0; debug_data->num_ray_bounces = 0; } @@ -30,16 +31,21 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg, int sample) { int flag = kernel_data.film.pass_flag; - if(flag & PASS_BVH_TRAVERSAL_STEPS) { - kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversal_steps, + if(flag & PASS_BVH_TRAVERSED_NODES) { + kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes, sample, - debug_data->num_bvh_traversal_steps); + debug_data->num_bvh_traversed_nodes); } if(flag & PASS_BVH_TRAVERSED_INSTANCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances, sample, debug_data->num_bvh_traversed_instances); } + if(flag & PASS_BVH_INTERSECTIONS) { + kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections, + sample, + debug_data->num_bvh_intersections); + } if(flag & PASS_RAY_BOUNCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces, sample, diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 6a36c68d69f..e25f2597366 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -634,8 +634,9 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg, #ifdef __KERNEL_DEBUG__ if(state.flag & PATH_RAY_CAMERA) { - debug_data.num_bvh_traversal_steps += isect.num_traversal_steps; + debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes; debug_data.num_bvh_traversed_instances += isect.num_traversed_instances; + debug_data.num_bvh_intersections += isect.num_intersections; } debug_data.num_ray_bounces++; #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 10174e1c4ce..72a8d98ac00 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -288,8 +288,9 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in #endif /* __HAIR__ */ #ifdef __KERNEL_DEBUG__ - debug_data.num_bvh_traversal_steps += isect.num_traversal_steps; + debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes; debug_data.num_bvh_traversed_instances += isect.num_traversed_instances; + debug_data.num_bvh_intersections += isect.num_intersections; debug_data.num_ray_bounces++; #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 2563f1491b1..4180465d1a1 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -345,9 +345,10 @@ typedef enum PassType { PASS_SUBSURFACE_COLOR = (1 << 24), PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */ #ifdef __KERNEL_DEBUG__ - PASS_BVH_TRAVERSAL_STEPS = (1 << 26), + PASS_BVH_TRAVERSED_NODES = (1 << 26), PASS_BVH_TRAVERSED_INSTANCES = (1 << 27), - PASS_RAY_BOUNCES = (1 << 28), + PASS_BVH_INTERSECTIONS = (1 << 28), + PASS_RAY_BOUNCES = (1 << 29), #endif } PassType; @@ -542,8 +543,9 @@ typedef ccl_addr_space struct Intersection { int type; #ifdef __KERNEL_DEBUG__ - int num_traversal_steps; + int num_traversed_nodes; int num_traversed_instances; + int num_intersections; #endif } Intersection; @@ -1040,10 +1042,10 @@ typedef struct KernelFilm { float mist_falloff; #ifdef __KERNEL_DEBUG__ - int pass_bvh_traversal_steps; + int pass_bvh_traversed_nodes; int pass_bvh_traversed_instances; + int pass_bvh_intersections; int pass_ray_bounces; - int pass_pad3; #endif } KernelFilm; static_assert_align(KernelFilm, 16); @@ -1188,10 +1190,9 @@ static_assert_align(KernelData, 16); * really important here. */ typedef ccl_addr_space struct DebugData { - // Total number of BVH node traversal steps and primitives intersections - // for the camera rays. - int num_bvh_traversal_steps; + int num_bvh_traversed_nodes; int num_bvh_traversed_instances; + int num_bvh_intersections; int num_ray_bounces; } DebugData; #endif diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h index fc4b4ee38e5..2388580051f 100644 --- a/intern/cycles/kernel/split/kernel_scene_intersect.h +++ b/intern/cycles/kernel/split/kernel_scene_intersect.h @@ -116,8 +116,9 @@ ccl_device void kernel_scene_intersect( #ifdef __KERNEL_DEBUG__ if(state.flag & PATH_RAY_CAMERA) { - debug_data->num_bvh_traversal_steps += isect->num_traversal_steps; + debug_data->num_bvh_traversed_nodes += isect->num_traversed_nodes; debug_data->num_bvh_traversed_instances += isect->num_traversed_instances; + debug_data->num_bvh_intersections += isect->num_intersections; } debug_data->num_ray_bounces++; #endif diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 6aca6ffa3ca..f1692712d61 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -185,8 +185,9 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int } } #ifdef WITH_CYCLES_DEBUG - else if(type == PASS_BVH_TRAVERSAL_STEPS || + else if(type == PASS_BVH_TRAVERSED_NODES || type == PASS_BVH_TRAVERSED_INSTANCES || + type == PASS_BVH_INTERSECTIONS || type == PASS_RAY_BOUNCES) { for(int i = 0; i < size; i++, in += pass_stride, pixels++) { diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 4cc9cb925c0..923252bb375 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -154,8 +154,9 @@ void Pass::add(PassType type, array<Pass>& passes) pass.components = 0; break; #ifdef WITH_CYCLES_DEBUG - case PASS_BVH_TRAVERSAL_STEPS: + case PASS_BVH_TRAVERSED_NODES: case PASS_BVH_TRAVERSED_INSTANCES: + case PASS_BVH_INTERSECTIONS: case PASS_RAY_BOUNCES: pass.components = 1; pass.exposure = false; @@ -415,12 +416,15 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) break; #ifdef WITH_CYCLES_DEBUG - case PASS_BVH_TRAVERSAL_STEPS: - kfilm->pass_bvh_traversal_steps = kfilm->pass_stride; + case PASS_BVH_TRAVERSED_NODES: + kfilm->pass_bvh_traversed_nodes = kfilm->pass_stride; break; case PASS_BVH_TRAVERSED_INSTANCES: kfilm->pass_bvh_traversed_instances = kfilm->pass_stride; break; + case PASS_BVH_INTERSECTIONS: + kfilm->pass_bvh_intersections = kfilm->pass_stride; + break; case PASS_RAY_BOUNCES: kfilm->pass_ray_bounces = kfilm->pass_stride; break; |