Code cleanup: make DebugData part of PathRadiance.
This commit is contained in:
parent
fce405059f
commit
7542282c06
|
@ -79,7 +79,6 @@ 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
|
||||
|
|
|
@ -233,7 +233,14 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
|
|||
L->denoising_normal = make_float3(0.0f, 0.0f, 0.0f);
|
||||
L->denoising_albedo = make_float3(0.0f, 0.0f, 0.0f);
|
||||
L->denoising_depth = 0.0f;
|
||||
#endif /* __DENOISING_FEATURES__ */
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
L->debug_data.num_bvh_traversed_nodes = 0;
|
||||
L->debug_data.num_bvh_traversed_instances = 0;
|
||||
L->debug_data.num_bvh_intersections = 0;
|
||||
L->debug_data.num_ray_bounces = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space float3 *throughput,
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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_traversed_nodes = 0;
|
||||
debug_data->num_bvh_traversed_instances = 0;
|
||||
debug_data->num_bvh_intersections = 0;
|
||||
debug_data->num_ray_bounces = 0;
|
||||
}
|
||||
|
||||
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
|
||||
ccl_global float *buffer,
|
||||
ccl_addr_space PathState *state,
|
||||
DebugData *debug_data,
|
||||
int sample)
|
||||
{
|
||||
int flag = kernel_data.film.pass_flag;
|
||||
if(flag & PASS_BVH_TRAVERSED_NODES) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes,
|
||||
sample,
|
||||
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,
|
||||
debug_data->num_ray_bounces);
|
||||
}
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
|
@ -194,6 +194,36 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
|
|||
#endif /* __DENOISING_FEATURES__ */
|
||||
}
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
|
||||
ccl_global float *buffer,
|
||||
PathRadiance *L,
|
||||
int sample)
|
||||
{
|
||||
int flag = kernel_data.film.pass_flag;
|
||||
if(flag & PASS_BVH_TRAVERSED_NODES) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes,
|
||||
sample,
|
||||
L->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,
|
||||
L->debug_data.num_bvh_traversed_instances);
|
||||
}
|
||||
if(flag & PASS_BVH_INTERSECTIONS) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections,
|
||||
sample,
|
||||
L->debug_data.num_bvh_intersections);
|
||||
}
|
||||
if(flag & PASS_RAY_BOUNCES) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
|
||||
sample,
|
||||
L->debug_data.num_ray_bounces);
|
||||
}
|
||||
}
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
|
||||
ShaderData *sd, int sample, ccl_addr_space PathState *state, float3 throughput)
|
||||
{
|
||||
|
@ -389,6 +419,11 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg, ccl_global float *
|
|||
sample, L->denoising_depth);
|
||||
}
|
||||
#endif /* __DENOISING_FEATURES__ */
|
||||
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, L, sample);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
kernel_write_pass_float4(buffer, sample, make_float4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
|
|
|
@ -48,10 +48,6 @@
|
|||
#include "kernel/kernel_path_volume.h"
|
||||
#include "kernel/kernel_path_subsurface.h"
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
# include "kernel/kernel_debug.h"
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
|
||||
|
@ -458,11 +454,6 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
PathState state;
|
||||
path_state_init(kg, &emission_sd, &state, rng, sample, &ray);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData debug_data;
|
||||
debug_data_init(&debug_data);
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
SubsurfaceIndirectRays ss_indirect;
|
||||
kernel_path_subsurface_init_indirect(&ss_indirect);
|
||||
|
@ -503,11 +494,11 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
if(state.flag & PATH_RAY_CAMERA) {
|
||||
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;
|
||||
L->debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
|
||||
L->debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
L.->ebug_data.num_bvh_intersections += isect.num_intersections;
|
||||
}
|
||||
debug_data.num_ray_bounces++;
|
||||
L->debug_data.num_ray_bounces++;
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
#ifdef __LAMP_MIS__
|
||||
|
@ -790,10 +781,6 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
*is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0;
|
||||
#endif /* __SHADOW_TRICKS__ */
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
return 1.0f - L_transparent;
|
||||
}
|
||||
|
||||
|
|
|
@ -291,11 +291,6 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
PathState state;
|
||||
path_state_init(kg, &emission_sd, &state, rng, sample, &ray);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData debug_data;
|
||||
debug_data_init(&debug_data);
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
/* Main Loop
|
||||
* Here we only handle transparency intersections from the camera ray.
|
||||
* Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
|
||||
|
@ -326,10 +321,10 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
#endif /* __HAIR__ */
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
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++;
|
||||
L->debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
|
||||
L->debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
L->debug_data.num_bvh_intersections += isect.num_intersections;
|
||||
L->debug_data.num_ray_bounces++;
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
#ifdef __VOLUME__
|
||||
|
@ -638,10 +633,6 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
*is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0;
|
||||
#endif /* __SHADOW_TRICKS__ */
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
||||
return 1.0f - L_transparent;
|
||||
}
|
||||
|
||||
|
|
|
@ -468,6 +468,18 @@ typedef enum DenoiseFlag {
|
|||
DENOISING_CLEAN_ALL_PASSES = (1 << 8)-1,
|
||||
} DenoiseFlag;
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
/* NOTE: This is a runtime-only struct, alignment is not
|
||||
* really important here.
|
||||
*/
|
||||
typedef struct DebugData {
|
||||
int num_bvh_traversed_nodes;
|
||||
int num_bvh_traversed_instances;
|
||||
int num_bvh_intersections;
|
||||
int num_ray_bounces;
|
||||
} DebugData;
|
||||
#endif
|
||||
|
||||
typedef ccl_addr_space struct PathRadiance {
|
||||
#ifdef __PASSES__
|
||||
int use_light_pass;
|
||||
|
@ -538,6 +550,10 @@ typedef ccl_addr_space struct PathRadiance {
|
|||
float3 denoising_albedo;
|
||||
float denoising_depth;
|
||||
#endif /* __DENOISING_FEATURES__ */
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData debug_data;
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
} PathRadiance;
|
||||
|
||||
typedef struct BsdfEval {
|
||||
|
@ -1345,18 +1361,6 @@ typedef struct KernelData {
|
|||
} KernelData;
|
||||
static_assert_align(KernelData, 16);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
/* NOTE: This is a runtime-only struct, alignment is not
|
||||
* really important here.
|
||||
*/
|
||||
typedef ccl_addr_space struct DebugData {
|
||||
int num_bvh_traversed_nodes;
|
||||
int num_bvh_traversed_instances;
|
||||
int num_bvh_intersections;
|
||||
int num_ray_bounces;
|
||||
} DebugData;
|
||||
#endif
|
||||
|
||||
/* Declarations required for split kernel */
|
||||
|
||||
/* Macro for queues */
|
||||
|
|
|
@ -79,9 +79,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
int stride = kernel_split_params.stride;
|
||||
|
||||
ccl_global char *ray_state = kernel_split_state.ray_state;
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData *debug_data = &kernel_split_state.debug_data[ray_index];
|
||||
#endif
|
||||
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
|
||||
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
|
||||
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
|
||||
|
@ -111,10 +108,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
buffer += (kernel_split_params.offset + pixel_x + pixel_y*stride) * kernel_data.film.pass_stride;
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, state, debug_data, sample);
|
||||
#endif
|
||||
|
||||
/* accumulate result in output buffer */
|
||||
bool is_shadow_catcher = (state->flag & PATH_RAY_SHADOW_CATCHER);
|
||||
kernel_write_result(kg, buffer, sample, L, 1.0f - (*L_transparent), is_shadow_catcher);
|
||||
|
@ -155,9 +148,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
path_state_init(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, &rng, sample, ray);
|
||||
#ifdef __SUBSURFACE__
|
||||
kernel_path_subsurface_init_indirect(&kernel_split_state.ss_rays[ray_index]);
|
||||
#endif
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
debug_data_init(debug_data);
|
||||
#endif
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
|
||||
enqueue_flag = 1;
|
||||
|
|
|
@ -86,10 +86,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) {
|
|||
#ifdef __SUBSURFACE__
|
||||
kernel_path_subsurface_init_indirect(&kernel_split_state.ss_rays[ray_index]);
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
debug_data_init(&kernel_split_state.debug_data[ray_index]);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* These rays do not participate in path-iteration. */
|
||||
|
|
|
@ -59,9 +59,6 @@ ccl_device void kernel_scene_intersect(KernelGlobals *kg)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData *debug_data = &kernel_split_state.debug_data[ray_index];
|
||||
#endif
|
||||
Intersection isect;
|
||||
PathState state = kernel_split_state.path_state[ray_index];
|
||||
Ray ray = kernel_split_state.ray[ray_index];
|
||||
|
@ -97,12 +94,14 @@ ccl_device void kernel_scene_intersect(KernelGlobals *kg)
|
|||
kernel_split_state.isect[ray_index] = isect;
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
|
||||
|
||||
if(state.flag & PATH_RAY_CAMERA) {
|
||||
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;
|
||||
L->debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
|
||||
L->debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
L->debug_data.num_bvh_intersections += isect.num_intersections;
|
||||
}
|
||||
debug_data->num_ray_bounces++;
|
||||
L->debug_data.num_ray_bounces++;
|
||||
#endif
|
||||
|
||||
if(!hit) {
|
||||
|
|
|
@ -56,14 +56,6 @@ typedef struct SplitParams {
|
|||
|
||||
/* SPLIT_DATA_ENTRY(type, name, num) */
|
||||
|
||||
#if defined(WITH_CYCLES_DEBUG) || defined(__KERNEL_DEBUG__)
|
||||
/* DebugData memory */
|
||||
# define SPLIT_DATA_DEBUG_ENTRIES \
|
||||
SPLIT_DATA_ENTRY(DebugData, debug_data, 1)
|
||||
#else
|
||||
# define SPLIT_DATA_DEBUG_ENTRIES
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef __BRANCHED_PATH__
|
||||
|
||||
typedef ccl_global struct SplitBranchedState {
|
||||
|
@ -139,7 +131,6 @@ typedef ccl_global struct SplitBranchedState {
|
|||
SPLIT_DATA_SUBSURFACE_ENTRIES \
|
||||
SPLIT_DATA_VOLUME_ENTRIES \
|
||||
SPLIT_DATA_BRANCHED_ENTRIES \
|
||||
SPLIT_DATA_DEBUG_ENTRIES \
|
||||
|
||||
/* entries to be copied to inactive rays when sharing branched samples (TODO: which are actually needed?) */
|
||||
#define SPLIT_DATA_ENTRIES_BRANCHED_SHARED \
|
||||
|
@ -158,7 +149,6 @@ typedef ccl_global struct SplitBranchedState {
|
|||
SPLIT_DATA_SUBSURFACE_ENTRIES \
|
||||
SPLIT_DATA_VOLUME_ENTRIES \
|
||||
SPLIT_DATA_BRANCHED_ENTRIES \
|
||||
SPLIT_DATA_DEBUG_ENTRIES \
|
||||
|
||||
/* struct that holds pointers to data in the shared state buffer */
|
||||
typedef struct SplitData {
|
||||
|
|
Loading…
Reference in New Issue