Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-10-04 17:00:26 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-10-04 17:00:26 +0400
commit27d660ad20a57a8f688890a04d2eb629e39a3f19 (patch)
tree218c119ef8908566cb411fce385cb51a72b7b85f /intern/cycles/kernel
parent8ac3c3d3ee229ba5b2df90f2276db1049bd104cc (diff)
Cycles: Add support for debug passes
Currently only summed number of traversal steps and intersections used by the camera ray intersection pass is implemented, but in the future we will support more debug passes which would help checking what things makes the scene slow. Example of such extra passes could be number of bounces, time spent on the shader tree evaluation and so. Implementation from the Cycles side is pretty much straightforward, could only mention here that it's a build-time option disabled by default. From the blender side it's implemented as a PASS_DEBUG with several subtypes possible. This way we don't need to create an extra DNA pass type for each of the debug passes, saving us a bits. Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D813
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/geom/geom_bvh_traversal.h12
-rw-r--r--intern/cycles/kernel/kernel_debug.h35
-rw-r--r--intern/cycles/kernel/kernel_path.h34
-rw-r--r--intern/cycles/kernel/kernel_types.h24
5 files changed, 106 insertions, 0 deletions
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 2d2eaa81211..c5ea3abc567 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -24,6 +24,7 @@ set(SRC_HEADERS
kernel_compat_cpu.h
kernel_compat_cuda.h
kernel_compat_opencl.h
+ kernel_debug.h
kernel_differential.h
kernel_emission.h
kernel_film.h
diff --git a/intern/cycles/kernel/geom/geom_bvh_traversal.h b/intern/cycles/kernel/geom/geom_bvh_traversal.h
index e39228c33de..eed54a4d00d 100644
--- a/intern/cycles/kernel/geom/geom_bvh_traversal.h
+++ b/intern/cycles/kernel/geom/geom_bvh_traversal.h
@@ -68,6 +68,10 @@ ccl_device bool BVH_FUNCTION_NAME
isect->u = 0.0f;
isect->v = 0.0f;
+#if defined(__KERNEL_DEBUG__)
+ isect->num_traversal_steps = 0;
+#endif
+
#if defined(__KERNEL_SSE2__)
const shuffle_swap_t shuf_identity = shuffle_swap_identity();
const shuffle_swap_t shuf_swap = shuffle_swap_swap();
@@ -226,6 +230,10 @@ ccl_device bool BVH_FUNCTION_NAME
--stackPtr;
}
}
+
+#if defined(__KERNEL_DEBUG__)
+ isect->num_traversal_steps++;
+#endif
}
/* if node is leaf, fetch triangle list */
@@ -274,6 +282,10 @@ ccl_device bool BVH_FUNCTION_NAME
}
}
+#if defined(__KERNEL_DEBUG__)
+ isect->num_traversal_steps++;
+#endif
+
/* shadow ray early termination */
#if defined(__KERNEL_SSE2__)
if(hit) {
diff --git a/intern/cycles/kernel/kernel_debug.h b/intern/cycles/kernel/kernel_debug.h
new file mode 100644
index 00000000000..81ce1e76420
--- /dev/null
+++ b/intern/cycles/kernel/kernel_debug.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011-2014 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+CCL_NAMESPACE_BEGIN
+
+ccl_device_inline void debug_data_init(DebugData *debug_data)
+{
+ debug_data->num_bvh_traversal_steps = 0;
+}
+
+ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
+ ccl_global float *buffer,
+ PathState *state,
+ DebugData *debug_data,
+ int sample)
+{
+ kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversal_steps,
+ sample,
+ debug_data->num_bvh_traversal_steps);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index e68a8370012..0e07d8a95f8 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -45,6 +45,10 @@
#include "kernel_path_surface.h"
#include "kernel_path_volume.h"
+#ifdef __KERNEL_DEBUG__
+# include "kernel_debug.h"
+#endif
+
CCL_NAMESPACE_BEGIN
ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, Ray ray,
@@ -473,6 +477,11 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
PathState state;
path_state_init(kg, &state, rng, sample, &ray);
+#ifdef __KERNEL_DEBUG__
+ DebugData debug_data;
+ debug_data_init(&debug_data);
+#endif
+
/* path iteration */
for(;;) {
/* intersect scene */
@@ -499,6 +508,12 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
+#ifdef __KERNEL_DEBUG__
+ if(state.flag & PATH_RAY_CAMERA) {
+ debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
+ }
+#endif
+
#ifdef __LAMP_MIS__
if(kernel_data.integrator.use_lamp_mis && !(state.flag & PATH_RAY_CAMERA)) {
/* ray starting from previous non-transparent bounce */
@@ -719,6 +734,10 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
kernel_write_light_passes(kg, buffer, &L, sample);
+#ifdef __KERNEL_DEBUG__
+ kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
+#endif
+
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
@@ -864,6 +883,11 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
PathState state;
path_state_init(kg, &state, rng, sample, &ray);
+#ifdef __KERNEL_DEBUG__
+ DebugData debug_data;
+ debug_data_init(&debug_data);
+#endif
+
for(;;) {
/* intersect scene */
Intersection isect;
@@ -889,6 +913,12 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
+#ifdef __KERNEL_DEBUG__
+ if(state.flag & PATH_RAY_CAMERA) {
+ debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
+ }
+#endif
+
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
if(state.volume_stack[0].shader != SHADER_NONE) {
@@ -1144,6 +1174,10 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
kernel_write_light_passes(kg, buffer, &L, sample);
+#ifdef __KERNEL_DEBUG__
+ kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
+#endif
+
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 2fe1cd87072..43becf14825 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -157,6 +157,10 @@ CCL_NAMESPACE_BEGIN
#define __HAIR__
#endif
+#ifdef WITH_CYCLES_DEBUG
+# define __KERNEL_DEBUG__
+#endif
+
/* Random Numbers */
typedef uint RNG;
@@ -313,6 +317,9 @@ typedef enum PassType {
PASS_SUBSURFACE_INDIRECT = 8388608,
PASS_SUBSURFACE_COLOR = 16777216,
PASS_LIGHT = 33554432, /* no real pass, used to force use_light_pass */
+#ifdef __KERNEL_DEBUG__
+ PASS_BVH_TRAVERSAL_STEPS = 67108864,
+#endif
} PassType;
#define PASS_ALL (~0)
@@ -453,6 +460,10 @@ typedef struct Intersection {
int prim;
int object;
int type;
+
+#ifdef __KERNEL_DEBUG__
+ int num_traversal_steps;
+#endif
} Intersection;
/* Primitives */
@@ -850,6 +861,11 @@ typedef struct KernelFilm {
float mist_start;
float mist_inv_depth;
float mist_falloff;
+
+#ifdef __KERNEL_DEBUG__
+ int pass_bvh_traversal_steps;
+ int pad[3];
+#endif
} KernelFilm;
typedef struct KernelBackground {
@@ -976,6 +992,14 @@ typedef struct KernelData {
KernelTables tables;
} KernelData;
+#ifdef __KERNEL_DEBUG__
+typedef struct DebugData {
+ // Total number of BVH node travesal steps and primitives intersections
+ // for the camera rays.
+ int num_bvh_traversal_steps;
+} DebugData;
+#endif
+
CCL_NAMESPACE_END
#endif /* __KERNEL_TYPES_H__ */