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
path: root/intern
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
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')
-rw-r--r--intern/cycles/CMakeLists.txt6
-rw-r--r--intern/cycles/SConscript3
-rw-r--r--intern/cycles/blender/blender_session.cpp11
-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
-rw-r--r--intern/cycles/render/buffers.cpp8
-rw-r--r--intern/cycles/render/film.cpp13
10 files changed, 147 insertions, 0 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index bfd29dcf606..981499b3a91 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -128,6 +128,7 @@ add_definitions(
-DWITH_MULTI
)
+# Logging capabilities using GLog library.
if(WITH_CYCLES_LOGGING)
add_definitions(-DWITH_CYCLES_LOGGING)
add_definitions(-DGOOGLE_GLOG_DLL_DECL=)
@@ -146,6 +147,11 @@ if(WITH_CYCLES_LOGGING)
endif()
endif()
+# Debugging capabilities (debug passes etc).
+if(WITH_CYCLES_DEBUG)
+ add_definitions(-DWITH_CYCLES_DEBUG)
+endif()
+
include_directories(
SYSTEM
${BOOST_INCLUDE_DIR}
diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript
index a6c947bfca8..594b43c88b2 100644
--- a/intern/cycles/SConscript
+++ b/intern/cycles/SConscript
@@ -59,6 +59,9 @@ if env['WITH_BF_CYCLES_OSL']:
defs.append('OSL_STATIC_LIBRARY')
incs.append(cycles['BF_OSL_INC'])
+if env['WITH_BF_CYCLES_DEBUG']:
+ defs.append('WITH_CYCLES_DEBUG')
+
incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna #source/blender/blenlib'.split())
incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split())
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 4ff3d89f9f1..0610c3f6579 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -261,6 +261,14 @@ static PassType get_pass_type(BL::RenderPass b_pass)
case BL::RenderPass::type_SPECULAR:
case BL::RenderPass::type_REFLECTION:
return PASS_NONE;
+#ifdef WITH_CYCLES_DEBUG
+ case BL::RenderPass::type_DEBUG:
+ {
+ if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS)
+ return PASS_BVH_TRAVERSAL_STEPS;
+ break;
+ }
+#endif
}
return PASS_NONE;
@@ -423,6 +431,9 @@ void BlenderSession::render()
/* add passes */
vector<Pass> passes;
Pass::add(PASS_COMBINED, passes);
+#ifdef WITH_CYCLES_DEBUG
+ Pass::add(PASS_BVH_TRAVERSAL_STEPS, passes);
+#endif
if(session_params.device.advanced_shading) {
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__ */
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index fc65922fc87..756e16b38b5 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -190,6 +190,14 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f);
}
}
+#ifdef WITH_CYCLES_DEBUG
+ else if(type == PASS_BVH_TRAVERSAL_STEPS) {
+ 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++) {
float f = *in;
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 09973e8bc86..19f959d4ea1 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -146,6 +146,12 @@ void Pass::add(PassType type, vector<Pass>& passes)
case PASS_LIGHT:
/* ignores */
break;
+#ifdef WITH_CYCLES_DEBUG
+ case PASS_BVH_TRAVERSAL_STEPS:
+ pass.components = 1;
+ pass.exposure = false;
+ break;
+#endif
}
passes.push_back(pass);
@@ -388,6 +394,13 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
case PASS_LIGHT:
kfilm->use_light_pass = 1;
break;
+
+#ifdef WITH_CYCLES_DEBUG
+ case PASS_BVH_TRAVERSAL_STEPS:
+ kfilm->pass_bvh_traversal_steps = kfilm->pass_stride;
+ break;
+#endif
+
case PASS_NONE:
break;
}