Cycles: Add debug pass showing average number of ray bounces per pixel

Quite straightforward implementation, but still needs some work for the split
kernel. Includes both regular and split kernel implementation for that.

The pass is not exposed to the interface yet because it's currently not really
easy to have same pass listed in the menu multiple times.
This commit is contained in:
Sergey Sharybin 2015-06-11 10:42:38 +02:00
parent 3438130a94
commit 2bd6de5bbb
10 changed files with 33 additions and 1 deletions

View File

@ -271,6 +271,8 @@ static PassType get_pass_type(BL::RenderPass b_pass)
{
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS)
return PASS_BVH_TRAVERSAL_STEPS;
if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES)
return PASS_RAY_BOUNCES;
break;
}
#endif
@ -439,6 +441,7 @@ void BlenderSession::render()
Pass::add(PASS_COMBINED, passes);
#ifdef WITH_CYCLES_DEBUG
Pass::add(PASS_BVH_TRAVERSAL_STEPS, passes);
/* Pass::add(PASS_RAY_BOUNCES, passes); */
#endif
if(session_params.device.advanced_shading) {

View File

@ -19,6 +19,7 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void debug_data_init(DebugData *debug_data)
{
debug_data->num_bvh_traversal_steps = 0;
debug_data->num_ray_bounces = 0;
}
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
@ -33,6 +34,11 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
sample,
debug_data->num_bvh_traversal_steps);
}
if(flag & PASS_RAY_BOUNCES) {
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
sample,
debug_data->num_ray_bounces);
}
}
CCL_NAMESPACE_END

View File

@ -477,6 +477,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
if(state.flag & PATH_RAY_CAMERA) {
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
}
debug_data.num_ray_bounces++;
#endif
#ifdef __LAMP_MIS__
@ -878,6 +879,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
if(state.flag & PATH_RAY_CAMERA) {
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
}
debug_data.num_ray_bounces++;
#endif
#ifdef __VOLUME__

View File

@ -337,6 +337,7 @@ typedef enum PassType {
PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */
#ifdef __KERNEL_DEBUG__
PASS_BVH_TRAVERSAL_STEPS = (1 << 26),
PASS_RAY_BOUNCES = (1 << 27),
#endif
} PassType;
@ -848,7 +849,8 @@ typedef struct KernelFilm {
#ifdef __KERNEL_DEBUG__
int pass_bvh_traversal_steps;
int pass_pad3, pass_pad4, pass_pad5;
int pass_ray_bounces;
int pass_pad3, pass_pad4;
#endif
} KernelFilm;
@ -987,6 +989,7 @@ 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_ray_bounces;
} DebugData;
#endif

View File

@ -124,6 +124,7 @@ ccl_device void kernel_scene_intersect(
if(state.flag & PATH_RAY_CAMERA) {
debug_data->num_bvh_traversal_steps += isect->num_traversal_steps;
}
debug_data->num_ray_bounces++;
#endif
if(!hit) {

View File

@ -197,6 +197,12 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[0] = f;
}
}
else if(type == PASS_RAY_BOUNCES) {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
pixels[0] = f;
}
}
#endif
else {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {

View File

@ -151,6 +151,10 @@ void Pass::add(PassType type, vector<Pass>& passes)
pass.components = 1;
pass.exposure = false;
break;
case PASS_RAY_BOUNCES:
pass.components = 1;
pass.exposure = false;
break;
#endif
}
@ -399,6 +403,9 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
case PASS_BVH_TRAVERSAL_STEPS:
kfilm->pass_bvh_traversal_steps = kfilm->pass_stride;
break;
case PASS_RAY_BOUNCES:
kfilm->pass_ray_bounces = kfilm->pass_stride;
break;
#endif
case PASS_NONE:

View File

@ -769,6 +769,7 @@ static void rna_def_render_pass(BlenderRNA *brna)
static EnumPropertyItem render_pass_debug_type_items[] = {
{RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS, "BVH_TRAVERSAL_STEPS", 0, "BVH Traversal Steps", ""},
{RENDER_PASS_DEBUG_RAY_BOUNCES, "RAY_BOUNCES", 0, "Ray Steps", ""},
{0, NULL, 0, NULL, NULL}
};

View File

@ -99,6 +99,7 @@ typedef struct RenderPass {
enum {
RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS = 0,
RENDER_PASS_DEBUG_RAY_BOUNCES = 1,
};
/* a renderlayer is a full image, but with all passes and samples */

View File

@ -531,6 +531,8 @@ static const char *debug_pass_type_name_get(int debug_type)
switch (debug_type) {
case RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS:
return "BVH Traversal Steps";
case RENDER_PASS_DEBUG_RAY_BOUNCES:
return "Ray Bounces";
}
return "Unknown";
}