Cycles: Add comments to endif directives

`kernel_path.h` and `kernel_path_branched.h` have a lot of conditional code and
it was kind of hard to tell what code belonged to which directive. Should be
easier to read now.
This commit is contained in:
Mai Lavelle 2016-10-06 14:55:56 +02:00
parent 80aae2b6fe
commit a1aa3a8b75
Notes: blender-bot 2023-02-14 08:06:35 +01:00
Referenced by issue #49996, Crash of Blender when using Video Sequencer Editor (VSE) and Grease Pencil (GP)
2 changed files with 49 additions and 49 deletions

View File

@ -84,7 +84,7 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
light_ray.t = kernel_data.background.ao_distance;
#ifdef __OBJECT_MOTION__
light_ray.time = ccl_fetch(sd, time);
#endif
#endif /* __OBJECT_MOTION__ */
light_ray.dP = ccl_fetch(sd, dP);
light_ray.dD = differential3_zero();
@ -138,7 +138,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
state->bounce);
}
}
#endif
#endif /* __LAMP_MIS__ */
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
@ -239,7 +239,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
}
}
else
# endif
# endif /* __VOLUME_DECOUPLED__ */
{
/* integrate along volume segment with distance sampling */
VolumeIntegrateResult result = kernel_volume_integrate(
@ -271,10 +271,10 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
break;
}
}
# endif
# endif /* __VOLUME_SCATTER__ */
}
}
#endif
#endif /* __VOLUME__ */
if(!hit) {
#ifdef __BACKGROUND__
@ -284,7 +284,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
throughput,
L_background,
state->bounce);
#endif
#endif /* __BACKGROUND__ */
break;
}
@ -298,7 +298,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
shader_eval_surface(kg, sd, rng, state, rbsdf, state->flag, SHADER_CONTEXT_INDIRECT);
#ifdef __BRANCHED_PATH__
shader_merge_closures(sd);
#endif
#endif /* __BRANCHED_PATH__ */
/* blurring of bsdf after bounces, for rays that have a small likelihood
* of following this particular path (diffuse, rough glossy) */
@ -321,7 +321,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
state->ray_pdf);
path_radiance_accum_emission(L, throughput, emission, state->bounce);
}
#endif
#endif /* __EMISSION__ */
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
@ -348,7 +348,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
kernel_path_ao(kg, sd, emission_sd, L, state, rng, throughput, make_float3(0.0f, 0.0f, 0.0f));
}
#endif
#endif /* __AO__ */
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
@ -380,7 +380,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
false);
}
}
#endif
#endif /* __SUBSURFACE__ */
#if defined(__EMISSION__) && defined(__BRANCHED_PATH__)
if(kernel_data.integrator.use_direct_light) {
@ -395,7 +395,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
L,
all);
}
#endif
#endif /* defined(__EMISSION__) && defined(__BRANCHED_PATH__) */
if(!kernel_path_surface_bounce(kg, rng, sd, &throughput, state, L, ray))
break;
@ -449,7 +449,7 @@ bool kernel_path_subsurface_scatter(
ss_indirect->need_update_volume_stack =
kernel_data.integrator.use_volumes &&
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
# endif
# endif /* __VOLUME__ */
/* compute lighting with the BSDF closure */
for(int hit = 0; hit < num_hits; hit++) {
@ -492,7 +492,7 @@ bool kernel_path_subsurface_scatter(
{
# ifdef __LAMP_MIS__
hit_state->ray_t = 0.0f;
# endif
# endif /* __LAMP_MIS__ */
# ifdef __VOLUME__
if(ss_indirect->need_update_volume_stack) {
@ -507,7 +507,7 @@ bool kernel_path_subsurface_scatter(
&volume_ray,
hit_state->volume_stack);
}
# endif
# endif /* __VOLUME__ */
path_radiance_reset_indirect(L);
ss_indirect->num_rays++;
}
@ -593,14 +593,14 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
#ifdef __KERNEL_DEBUG__
DebugData debug_data;
debug_data_init(&debug_data);
#endif
#endif /* __KERNEL_DEBUG__ */
#ifdef __SUBSURFACE__
SubsurfaceIndirectRays ss_indirect;
kernel_path_subsurface_init_indirect(&ss_indirect);
for(;;) {
#endif
#endif /* __SUBSURFACE__ */
/* path iteration */
for(;;) {
@ -626,7 +626,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
#else
bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
#endif /* __HAIR__ */
#ifdef __KERNEL_DEBUG__
if(state.flag & PATH_RAY_CAMERA) {
@ -634,7 +634,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
}
debug_data.num_ray_bounces++;
#endif
#endif /* __KERNEL_DEBUG__ */
#ifdef __LAMP_MIS__
if(kernel_data.integrator.use_lamp_mis && !(state.flag & PATH_RAY_CAMERA)) {
@ -655,7 +655,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
if(indirect_lamp_emission(kg, &emission_sd, &state, &light_ray, &emission))
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
#endif /* __LAMP_MIS__ */
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
@ -719,7 +719,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
}
}
else
# endif
# endif /* __VOLUME_DECOUPLED__ */
{
/* integrate along volume segment with distance sampling */
VolumeIntegrateResult result = kernel_volume_integrate(
@ -736,10 +736,10 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
else
break;
}
# endif
# endif /* __VOLUME_SCATTER__ */
}
}
#endif
#endif /* __VOLUME__ */
if(!hit) {
/* eval background shader if nothing hit */
@ -748,7 +748,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
#ifdef __PASSES__
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
#endif
#endif /* __PASSES__ */
break;
}
@ -756,7 +756,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
/* sample background shader */
float3 L_background = indirect_background(kg, &emission_sd, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
#endif /* __BACKGROUND__ */
break;
}
@ -784,7 +784,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
if(sd.flag & SD_HOLDOUT_MASK)
break;
}
#endif
#endif /* __HOLDOUT__ */
/* holdout mask objects do not write data passes */
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
@ -807,7 +807,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
#endif /* __EMISSION__ */
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
@ -830,7 +830,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
kernel_path_ao(kg, &sd, &emission_sd, &L, &state, rng, throughput, shader_bsdf_alpha(kg, &sd));
}
#endif
#endif /* __AO__ */
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
@ -885,7 +885,7 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
#endif
#endif /* __KERNEL_DEBUG__ */
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}

View File

@ -51,7 +51,7 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
light_ray.t = kernel_data.background.ao_distance;
#ifdef __OBJECT_MOTION__
light_ray.time = ccl_fetch(sd, time);
#endif
#endif /* __OBJECT_MOTION__ */
light_ray.dP = ccl_fetch(sd, dP);
light_ray.dD = differential3_zero();
@ -169,7 +169,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
Ray volume_ray = *ray;
bool need_update_volume_stack = kernel_data.integrator.use_volumes &&
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
#endif
#endif /* __VOLUME__ */
/* compute lighting with the BSDF closure */
for(int hit = 0; hit < num_hits; hit++) {
@ -200,7 +200,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
&volume_ray,
hit_state.volume_stack);
}
#endif
#endif /* __VOLUME__ */
#ifdef __EMISSION__
/* direct light */
@ -217,7 +217,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
L,
all);
}
#endif
#endif /* __EMISSION__ */
/* indirect light */
kernel_branched_path_surface_indirect_light(
@ -234,7 +234,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
}
}
}
#endif
#endif /* __SUBSURFACE__ */
ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
@ -256,7 +256,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
#ifdef __KERNEL_DEBUG__
DebugData debug_data;
debug_data_init(&debug_data);
#endif
#endif /* __KERNEL_DEBUG__ */
/* Main Loop
* Here we only handle transparency intersections from the camera ray.
@ -285,13 +285,13 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
#else
bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
#endif /* __HAIR__ */
#ifdef __KERNEL_DEBUG__
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++;
#endif
#endif /* __KERNEL_DEBUG__ */
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
@ -432,14 +432,14 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
path_radiance_reset_indirect(&L);
}
}
#endif
#endif /* __VOLUME_SCATTER__ */
}
/* todo: avoid this calculation using decoupled ray marching */
kernel_volume_shadow(kg, &emission_sd, &state, &volume_ray, &throughput);
#endif
#endif /* __VOLUME_DECOUPLED__ */
}
#endif
#endif /* __VOLUME__ */
if(!hit) {
/* eval background shader if nothing hit */
@ -448,7 +448,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
#ifdef __PASSES__
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
#endif
#endif /* __PASSES__ */
break;
}
@ -456,7 +456,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
/* sample background shader */
float3 L_background = indirect_background(kg, &emission_sd, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
#endif /* __BACKGROUND__ */
break;
}
@ -484,7 +484,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
if(sd.flag & SD_HOLDOUT_MASK)
break;
}
#endif
#endif /* __HOLDOUT__ */
/* holdout mask objects do not write data passes */
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
@ -495,7 +495,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
#endif /* __EMISSION__ */
/* transparency termination */
if(state.flag & PATH_RAY_TRANSPARENT) {
@ -522,7 +522,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
kernel_branched_path_ao(kg, &sd, &emission_sd, &L, &state, rng, throughput);
}
#endif
#endif /* __AO__ */
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object */
@ -530,7 +530,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
kernel_branched_path_subsurface_scatter(kg, &sd, &indirect_sd, &emission_sd,
&L, &state, rng, &ray, throughput);
}
#endif
#endif /* __SUBSURFACE__ */
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
PathState hit_state = state;
@ -542,7 +542,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
kernel_branched_path_surface_connect_light(kg, rng,
&sd, &emission_sd, &hit_state, throughput, 1.0f, &L, all);
}
#endif
#endif /* __EMISSION__ */
/* indirect light */
kernel_branched_path_surface_indirect_light(kg, rng,
@ -567,12 +567,12 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
ray.dP = sd.dP;
ray.dD.dx = -sd.dI.dx;
ray.dD.dy = -sd.dI.dy;
#endif
#endif /* __RAY_DIFFERENTIALS__ */
#ifdef __VOLUME__
/* enter/exit volume */
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
#endif
#endif /* __VOLUME__ */
}
float3 L_sum = path_radiance_clamp_and_sum(kg, &L);
@ -581,7 +581,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
#endif
#endif /* __KERNEL_DEBUG__ */
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}