Cycles: Add debug pass which shows number of instance pushes during camera ray intersection
TODO: We might want to refactor debug passes into PASS_DEBUG and some debug_type (similar to Blender's side passes) to avoid issue of running out of bits.
This commit is contained in:
@@ -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)
|
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS)
|
||||||
return PASS_BVH_TRAVERSAL_STEPS;
|
return PASS_BVH_TRAVERSAL_STEPS;
|
||||||
|
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES)
|
||||||
|
return PASS_BVH_TRAVERSED_INSTANCES;
|
||||||
if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES)
|
if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES)
|
||||||
return PASS_RAY_BOUNCES;
|
return PASS_RAY_BOUNCES;
|
||||||
break;
|
break;
|
||||||
|
@@ -76,6 +76,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
|||||||
|
|
||||||
#if defined(__KERNEL_DEBUG__)
|
#if defined(__KERNEL_DEBUG__)
|
||||||
isect->num_traversal_steps = 0;
|
isect->num_traversal_steps = 0;
|
||||||
|
isect->num_traversed_instances = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__KERNEL_SSE2__)
|
#if defined(__KERNEL_SSE2__)
|
||||||
@@ -362,6 +363,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
|||||||
traversalStack[stackPtr] = ENTRYPOINT_SENTINEL;
|
traversalStack[stackPtr] = ENTRYPOINT_SENTINEL;
|
||||||
|
|
||||||
nodeAddr = kernel_tex_fetch(__object_node, object);
|
nodeAddr = kernel_tex_fetch(__object_node, object);
|
||||||
|
|
||||||
|
#if defined(__KERNEL_DEBUG__)
|
||||||
|
isect->num_traversed_instances++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* FEATURE(BVH_INSTANCING) */
|
#endif /* FEATURE(BVH_INSTANCING) */
|
||||||
|
@@ -80,6 +80,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
|||||||
|
|
||||||
#if defined(__KERNEL_DEBUG__)
|
#if defined(__KERNEL_DEBUG__)
|
||||||
isect->num_traversal_steps = 0;
|
isect->num_traversal_steps = 0;
|
||||||
|
isect->num_traversed_instances = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssef tnear(0.0f), tfar(ray->t);
|
ssef tnear(0.0f), tfar(ray->t);
|
||||||
@@ -377,6 +378,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
|||||||
traversalStack[stackPtr].dist = -FLT_MAX;
|
traversalStack[stackPtr].dist = -FLT_MAX;
|
||||||
|
|
||||||
nodeAddr = kernel_tex_fetch(__object_node, object);
|
nodeAddr = kernel_tex_fetch(__object_node, object);
|
||||||
|
|
||||||
|
#if defined(__KERNEL_DEBUG__)
|
||||||
|
isect->num_traversed_instances++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* FEATURE(BVH_INSTANCING) */
|
#endif /* FEATURE(BVH_INSTANCING) */
|
||||||
|
@@ -19,6 +19,7 @@ CCL_NAMESPACE_BEGIN
|
|||||||
ccl_device_inline void debug_data_init(DebugData *debug_data)
|
ccl_device_inline void debug_data_init(DebugData *debug_data)
|
||||||
{
|
{
|
||||||
debug_data->num_bvh_traversal_steps = 0;
|
debug_data->num_bvh_traversal_steps = 0;
|
||||||
|
debug_data->num_bvh_traversed_instances = 0;
|
||||||
debug_data->num_ray_bounces = 0;
|
debug_data->num_ray_bounces = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +35,11 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
|
|||||||
sample,
|
sample,
|
||||||
debug_data->num_bvh_traversal_steps);
|
debug_data->num_bvh_traversal_steps);
|
||||||
}
|
}
|
||||||
|
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_RAY_BOUNCES) {
|
if(flag & PASS_RAY_BOUNCES) {
|
||||||
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
|
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
|
||||||
sample,
|
sample,
|
||||||
|
@@ -476,6 +476,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
|
|||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
if(state.flag & PATH_RAY_CAMERA) {
|
if(state.flag & PATH_RAY_CAMERA) {
|
||||||
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
||||||
|
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||||
}
|
}
|
||||||
debug_data.num_ray_bounces++;
|
debug_data.num_ray_bounces++;
|
||||||
#endif
|
#endif
|
||||||
@@ -878,6 +879,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
|
|||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
if(state.flag & PATH_RAY_CAMERA) {
|
if(state.flag & PATH_RAY_CAMERA) {
|
||||||
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
||||||
|
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||||
}
|
}
|
||||||
debug_data.num_ray_bounces++;
|
debug_data.num_ray_bounces++;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -339,7 +339,8 @@ typedef enum PassType {
|
|||||||
PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */
|
PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */
|
||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
PASS_BVH_TRAVERSAL_STEPS = (1 << 26),
|
PASS_BVH_TRAVERSAL_STEPS = (1 << 26),
|
||||||
PASS_RAY_BOUNCES = (1 << 27),
|
PASS_BVH_TRAVERSED_INSTANCES = (1 << 27),
|
||||||
|
PASS_RAY_BOUNCES = (1 << 28),
|
||||||
#endif
|
#endif
|
||||||
} PassType;
|
} PassType;
|
||||||
|
|
||||||
@@ -501,6 +502,7 @@ typedef ccl_addr_space struct Intersection {
|
|||||||
|
|
||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
int num_traversal_steps;
|
int num_traversal_steps;
|
||||||
|
int num_traversed_instances;
|
||||||
#endif
|
#endif
|
||||||
} Intersection;
|
} Intersection;
|
||||||
|
|
||||||
@@ -851,8 +853,9 @@ typedef struct KernelFilm {
|
|||||||
|
|
||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
int pass_bvh_traversal_steps;
|
int pass_bvh_traversal_steps;
|
||||||
|
int pass_bvh_traversed_instances;
|
||||||
int pass_ray_bounces;
|
int pass_ray_bounces;
|
||||||
int pass_pad3, pass_pad4;
|
int pass_pad3;
|
||||||
#endif
|
#endif
|
||||||
} KernelFilm;
|
} KernelFilm;
|
||||||
|
|
||||||
@@ -991,6 +994,7 @@ typedef ccl_addr_space struct DebugData {
|
|||||||
// Total number of BVH node traversal steps and primitives intersections
|
// Total number of BVH node traversal steps and primitives intersections
|
||||||
// for the camera rays.
|
// for the camera rays.
|
||||||
int num_bvh_traversal_steps;
|
int num_bvh_traversal_steps;
|
||||||
|
int num_bvh_traversed_instances;
|
||||||
int num_ray_bounces;
|
int num_ray_bounces;
|
||||||
} DebugData;
|
} DebugData;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -123,6 +123,7 @@ ccl_device void kernel_scene_intersect(
|
|||||||
#ifdef __KERNEL_DEBUG__
|
#ifdef __KERNEL_DEBUG__
|
||||||
if(state.flag & PATH_RAY_CAMERA) {
|
if(state.flag & PATH_RAY_CAMERA) {
|
||||||
debug_data->num_bvh_traversal_steps += isect->num_traversal_steps;
|
debug_data->num_bvh_traversal_steps += isect->num_traversal_steps;
|
||||||
|
debug_data->num_bvh_traversed_instances += isect->num_traversed_instances;
|
||||||
}
|
}
|
||||||
debug_data->num_ray_bounces++;
|
debug_data->num_ray_bounces++;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -151,6 +151,10 @@ void Pass::add(PassType type, vector<Pass>& passes)
|
|||||||
pass.components = 1;
|
pass.components = 1;
|
||||||
pass.exposure = false;
|
pass.exposure = false;
|
||||||
break;
|
break;
|
||||||
|
case PASS_BVH_TRAVERSED_INSTANCES:
|
||||||
|
pass.components = 1;
|
||||||
|
pass.exposure = false;
|
||||||
|
break;
|
||||||
case PASS_RAY_BOUNCES:
|
case PASS_RAY_BOUNCES:
|
||||||
pass.components = 1;
|
pass.components = 1;
|
||||||
pass.exposure = false;
|
pass.exposure = false;
|
||||||
@@ -403,6 +407,9 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
|||||||
case PASS_BVH_TRAVERSAL_STEPS:
|
case PASS_BVH_TRAVERSAL_STEPS:
|
||||||
kfilm->pass_bvh_traversal_steps = kfilm->pass_stride;
|
kfilm->pass_bvh_traversal_steps = kfilm->pass_stride;
|
||||||
break;
|
break;
|
||||||
|
case PASS_BVH_TRAVERSED_INSTANCES:
|
||||||
|
kfilm->pass_bvh_traversed_instances = kfilm->pass_stride;
|
||||||
|
break;
|
||||||
case PASS_RAY_BOUNCES:
|
case PASS_RAY_BOUNCES:
|
||||||
kfilm->pass_ray_bounces = kfilm->pass_stride;
|
kfilm->pass_ray_bounces = kfilm->pass_stride;
|
||||||
break;
|
break;
|
||||||
|
@@ -79,6 +79,7 @@ EnumPropertyItem render_pass_type_items[] = {
|
|||||||
|
|
||||||
EnumPropertyItem render_pass_debug_type_items[] = {
|
EnumPropertyItem render_pass_debug_type_items[] = {
|
||||||
{RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS, "BVH_TRAVERSAL_STEPS", 0, "BVH Traversal Steps", ""},
|
{RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS, "BVH_TRAVERSAL_STEPS", 0, "BVH Traversal Steps", ""},
|
||||||
|
{RENDER_PASS_DEBUG_BVH_TRAVERSED_INSTANCES, "BVH_TRAVERSED_INSTANCES", 0, "BVH Traversed Instances", ""},
|
||||||
{RENDER_PASS_DEBUG_RAY_BOUNCES, "RAY_BOUNCES", 0, "Ray Steps", ""},
|
{RENDER_PASS_DEBUG_RAY_BOUNCES, "RAY_BOUNCES", 0, "Ray Steps", ""},
|
||||||
{0, NULL, 0, NULL, NULL}
|
{0, NULL, 0, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@@ -99,7 +99,8 @@ typedef struct RenderPass {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS = 0,
|
RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS = 0,
|
||||||
RENDER_PASS_DEBUG_RAY_BOUNCES = 1,
|
RENDER_PASS_DEBUG_BVH_TRAVERSED_INSTANCES = 1,
|
||||||
|
RENDER_PASS_DEBUG_RAY_BOUNCES = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* a renderlayer is a full image, but with all passes and samples */
|
/* a renderlayer is a full image, but with all passes and samples */
|
||||||
|
@@ -531,6 +531,8 @@ static const char *debug_pass_type_name_get(int debug_type)
|
|||||||
switch (debug_type) {
|
switch (debug_type) {
|
||||||
case RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS:
|
case RENDER_PASS_DEBUG_BVH_TRAVERSAL_STEPS:
|
||||||
return "BVH Traversal Steps";
|
return "BVH Traversal Steps";
|
||||||
|
case RENDER_PASS_DEBUG_BVH_TRAVERSED_INSTANCES:
|
||||||
|
return "BVH Traversed Instances";
|
||||||
case RENDER_PASS_DEBUG_RAY_BOUNCES:
|
case RENDER_PASS_DEBUG_RAY_BOUNCES:
|
||||||
return "Ray Bounces";
|
return "Ray Bounces";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user