Cycles: reduce subsurface stack memory usage.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 23 Aug 2017 01:57:27 +0000 (03:57 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 28 Sep 2017 13:18:43 +0000 (15:18 +0200)
This is done by storing only a subset of PathRadiance, and by storing
direct light immediately in the main PathRadiance. Saves about 10% of
CUDA stack memory, and simplifies subsurface indirect ray code.

12 files changed:
intern/cycles/kernel/kernel_accumulate.h
intern/cycles/kernel/kernel_bake.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_path_subsurface.h
intern/cycles/kernel/kernel_path_surface.h
intern/cycles/kernel/kernel_path_volume.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/split/kernel_branched.h
intern/cycles/kernel/split/kernel_do_volume.h
intern/cycles/kernel/split/kernel_indirect_subsurface.h
intern/cycles/kernel/split/kernel_next_iteration_setup.h

index 5e60458655798d87f69aeec1d7ee2129de55fd98..ae5f6e5e07052429e5a14ffd481a02ea48773e68 100644 (file)
@@ -181,7 +181,6 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
 
        if(use_light_pass) {
                L->indirect = make_float3(0.0f, 0.0f, 0.0f);
-               L->direct_throughput = make_float3(0.0f, 0.0f, 0.0f);
                L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
 
                L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f);
@@ -202,18 +201,19 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
                L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
                L->indirect_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
-               L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
-
                L->transparent = 0.0f;
                L->emission = make_float3(0.0f, 0.0f, 0.0f);
                L->background = make_float3(0.0f, 0.0f, 0.0f);
                L->ao = make_float3(0.0f, 0.0f, 0.0f);
                L->shadow = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
                L->mist = 0.0f;
+
+               L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.glossy = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.transmission = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.subsurface = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.scatter = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.direct = make_float3(0.0f, 0.0f, 0.0f);
        }
        else
 #endif
@@ -245,26 +245,34 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
 #endif
 }
 
-ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space float3 *throughput,
-       BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
+ccl_device_inline void path_radiance_bsdf_bounce(
+       KernelGlobals *kg,
+       PathRadianceState *L_state,
+       ccl_addr_space float3 *throughput,
+       BsdfEval *bsdf_eval,
+       float bsdf_pdf, int bounce, int bsdf_label)
 {
        float inverse_pdf = 1.0f/bsdf_pdf;
 
 #ifdef __PASSES__
-       if(L->use_light_pass) {
+       if(kernel_data.film.use_light_pass) {
                if(bounce == 0 && !(bsdf_label & LABEL_TRANSPARENT)) {
                        /* first on directly visible surface */
                        float3 value = *throughput*inverse_pdf;
 
-                       L->path_diffuse = bsdf_eval->diffuse*value;
-                       L->path_glossy = bsdf_eval->glossy*value;
-                       L->path_transmission = bsdf_eval->transmission*value;
-                       L->path_subsurface = bsdf_eval->subsurface*value;
-                       L->path_scatter = bsdf_eval->scatter*value;
-
-                       *throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface + L->path_scatter;
+                       L_state->diffuse = bsdf_eval->diffuse*value;
+                       L_state->glossy = bsdf_eval->glossy*value;
+                       L_state->transmission = bsdf_eval->transmission*value;
+                       L_state->subsurface = bsdf_eval->subsurface*value;
+                       L_state->scatter = bsdf_eval->scatter*value;
+
+                       *throughput = L_state->diffuse +
+                                     L_state->glossy +
+                                     L_state->transmission +
+                                     L_state->subsurface +
+                                     L_state->scatter;
                        
-                       L->direct_throughput = *throughput;
+                       L_state->direct = *throughput;
                }
                else {
                        /* transparent bounce before first hit, or indirectly visible through BSDF */
@@ -493,19 +501,19 @@ ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
         * only a single throughput further along the path, here we recover just
         * the indirect path that is not influenced by any particular BSDF type */
        if(L->use_light_pass) {
-               L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput);
-               L->direct_diffuse += L->path_diffuse*L->direct_emission;
-               L->direct_glossy += L->path_glossy*L->direct_emission;
-               L->direct_transmission += L->path_transmission*L->direct_emission;
-               L->direct_subsurface += L->path_subsurface*L->direct_emission;
-               L->direct_scatter += L->path_scatter*L->direct_emission;
+               L->direct_emission = safe_divide_color(L->direct_emission, L->state.direct);
+               L->direct_diffuse += L->state.diffuse*L->direct_emission;
+               L->direct_glossy += L->state.glossy*L->direct_emission;
+               L->direct_transmission += L->state.transmission*L->direct_emission;
+               L->direct_subsurface += L->state.subsurface*L->direct_emission;
+               L->direct_scatter += L->state.scatter*L->direct_emission;
 
-               L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
-               L->indirect_diffuse += L->path_diffuse*L->indirect;
-               L->indirect_glossy += L->path_glossy*L->indirect;
-               L->indirect_transmission += L->path_transmission*L->indirect;
-               L->indirect_subsurface += L->path_subsurface*L->indirect;
-               L->indirect_scatter += L->path_scatter*L->indirect;
+               L->indirect = safe_divide_color(L->indirect, L->state.direct);
+               L->indirect_diffuse += L->state.diffuse*L->indirect;
+               L->indirect_glossy += L->state.glossy*L->indirect;
+               L->indirect_transmission += L->state.transmission*L->indirect;
+               L->indirect_subsurface += L->state.subsurface*L->indirect;
+               L->indirect_scatter += L->state.scatter*L->indirect;
        }
 #endif
 }
@@ -514,11 +522,11 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
 {
 #ifdef __PASSES__
        if(L->use_light_pass) {
-               L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
-               L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.glossy = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.transmission = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.subsurface = make_float3(0.0f, 0.0f, 0.0f);
+               L->state.scatter = make_float3(0.0f, 0.0f, 0.0f);
 
                L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
                L->indirect = make_float3(0.0f, 0.0f, 0.0f);
@@ -531,11 +539,7 @@ ccl_device_inline void path_radiance_copy_indirect(PathRadiance *L,
 {
 #ifdef __PASSES__
        if(L->use_light_pass) {
-               L->path_diffuse = L_src->path_diffuse;
-               L->path_glossy = L_src->path_glossy;
-               L->path_transmission = L_src->path_transmission;
-               L->path_subsurface = L_src->path_subsurface;
-               L->path_scatter = L_src->path_scatter;
+               L->state = L_src->state;
 
                L->direct_emission = L_src->direct_emission;
                L->indirect = L_src->indirect;
index f06005c50726f53bff0cdb6aa05252f2deb0958e..4d89839c46c81f28022fca52c0f826c292fcc20d 100644 (file)
@@ -103,7 +103,6 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
                                                             throughput,
                                                             &state,
                                                             &L_sample);
-                                       kernel_path_subsurface_accum_indirect(&ss_indirect, &L_sample);
                                }
                                is_sss_sample = true;
                        }
@@ -114,7 +113,7 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
                if(!is_sss_sample && (pass_filter & (BAKE_FILTER_DIRECT | BAKE_FILTER_INDIRECT))) {
                        kernel_path_surface_connect_light(kg, sd, &emission_sd, throughput, &state, &L_sample);
 
-                       if(kernel_path_surface_bounce(kg, sd, &throughput, &state, &L_sample, &ray)) {
+                       if(kernel_path_surface_bounce(kg, sd, &throughput, &state, &L_sample.state, &ray)) {
 #ifdef __LAMP_MIS__
                                state.ray_t = 0.0f;
 #endif
index d43d6374c13f85d9f21d74dd29476505e2b2fbe4..793fede0deb93187eca0d682ddcc9e1fa10c3a1b 100644 (file)
@@ -222,7 +222,7 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(
                        kernel_volume_decoupled_free(kg, &volume_segment);
 
                        if(result == VOLUME_PATH_SCATTERED) {
-                               if(kernel_path_volume_bounce(kg, sd, throughput, state, L, ray))
+                               if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
                                        return VOLUME_PATH_SCATTERED;
                                else
                                        return VOLUME_PATH_MISSED;
@@ -244,7 +244,7 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(
                                kernel_path_volume_connect_light(kg, sd, emission_sd, *throughput, state, L);
 
                                /* indirect light bounce */
-                               if(kernel_path_volume_bounce(kg, sd, throughput, state, L, ray))
+                               if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
                                        return VOLUME_PATH_SCATTERED;
                                else
                                        return VOLUME_PATH_MISSED;
@@ -519,7 +519,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                }
 #endif  /* defined(__EMISSION__) */
 
-               if(!kernel_path_surface_bounce(kg, sd, &throughput, state, L, ray))
+               if(!kernel_path_surface_bounce(kg, sd, &throughput, state, &L->state, ray))
                        break;
        }
 }
@@ -648,13 +648,11 @@ ccl_device_forceinline void kernel_path_integrate(
                kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, state, L);
 
                /* compute direct lighting and next bounce */
-               if(!kernel_path_surface_bounce(kg, &sd, &throughput, state, L, ray))
+               if(!kernel_path_surface_bounce(kg, &sd, &throughput, state, &L->state, ray))
                        break;
        }
 
 #ifdef __SUBSURFACE__
-               kernel_path_subsurface_accum_indirect(&ss_indirect, L);
-
                /* Trace indirect subsurface rays by restarting the loop. this uses less
                 * stack memory than invoking kernel_path_indirect.
                 */
index 010988d2a02f844bf1104451fcdd4303f6e8143a..6e0ec22d581481b9e33fe62a15f6532d812b54df 100644 (file)
@@ -128,7 +128,7 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
                                                                num_samples,
                                                                &tp,
                                                                &ps,
-                                                               L,
+                                                               &L->state,
                                                                &bsdf_ray,
                                                                sum_sample_weight))
                        {
@@ -350,7 +350,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
                                                                     &sd,
                                                                     &tp,
                                                                     &ps,
-                                                                    L,
+                                                                    &L->state,
                                                                     &pray))
                                        {
                                                kernel_path_indirect(kg,
@@ -405,7 +405,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
                                                                     &sd,
                                                                     &tp,
                                                                     &ps,
-                                                                    L,
+                                                                    &L->state,
                                                                     &pray))
                                        {
                                                kernel_path_indirect(kg,
index 1753618607ae69e81bb8b44dc7946a9cefbfa482..1436e8e5a5b0d5af75709e9fc623bc261c741332 100644 (file)
@@ -43,7 +43,7 @@ bool kernel_path_subsurface_scatter(
                 * the second one should be converted to a diffuse BSDF to
                 * avoid this.
                 */
-               kernel_assert(!ss_indirect->tracing);
+               kernel_assert(!(state->flag & PATH_RAY_DIFFUSE_ANCESTOR));
 
                uint lcg_state = lcg_state_init_addrspace(state, 0x68bc21eb);
 
@@ -56,7 +56,7 @@ bool kernel_path_subsurface_scatter(
                                                                  bssrdf_u, bssrdf_v,
                                                                  false);
 #  ifdef __VOLUME__
-               ss_indirect->need_update_volume_stack =
+               bool need_update_volume_stack =
                        kernel_data.integrator.use_volumes &&
                        sd->object_flag & SD_OBJECT_INTERSECTS_VOLUME;
 #  endif  /* __VOLUME__ */
@@ -75,28 +75,25 @@ bool kernel_path_subsurface_scatter(
                                                       sc,
                                                       false);
 
+                       kernel_path_surface_connect_light(kg, sd, emission_sd, *throughput, state, L);
+
                        ccl_addr_space PathState *hit_state = &ss_indirect->state[ss_indirect->num_rays];
                        ccl_addr_space Ray *hit_ray = &ss_indirect->rays[ss_indirect->num_rays];
                        ccl_addr_space float3 *hit_tp = &ss_indirect->throughputs[ss_indirect->num_rays];
-                       PathRadiance *hit_L = &ss_indirect->L[ss_indirect->num_rays];
+                       PathRadianceState *hit_L_state = &ss_indirect->L_state[ss_indirect->num_rays];
 
                        *hit_state = *state;
                        *hit_ray = *ray;
                        *hit_tp = *throughput;
+                       *hit_L_state = L->state;
 
                        hit_state->rng_offset += PRNG_BOUNCE_NUM;
 
-                       path_radiance_init(hit_L, kernel_data.film.use_light_pass);
-                       hit_L->direct_throughput = L->direct_throughput;
-                       path_radiance_copy_indirect(hit_L, L);
-
-                       kernel_path_surface_connect_light(kg, sd, emission_sd, *hit_tp, state, hit_L);
-
                        if(kernel_path_surface_bounce(kg,
                                                      sd,
                                                      hit_tp,
                                                      hit_state,
-                                                     hit_L,
+                                                     hit_L_state,
                                                      hit_ray))
                        {
 #  ifdef __LAMP_MIS__
@@ -104,7 +101,7 @@ bool kernel_path_subsurface_scatter(
 #  endif  /* __LAMP_MIS__ */
 
 #  ifdef __VOLUME__
-                               if(ss_indirect->need_update_volume_stack) {
+                               if(need_update_volume_stack) {
                                        Ray volume_ray = *ray;
                                        /* Setup ray from previous surface point to the new one. */
                                        volume_ray.D = normalize_len(hit_ray->P - volume_ray.P,
@@ -117,12 +114,8 @@ bool kernel_path_subsurface_scatter(
                                            hit_state->volume_stack);
                                }
 #  endif  /* __VOLUME__ */
-                               path_radiance_reset_indirect(L);
                                ss_indirect->num_rays++;
                        }
-                       else {
-                               path_radiance_accum_sample(L, hit_L);
-                       }
                }
                return true;
        }
@@ -132,23 +125,9 @@ bool kernel_path_subsurface_scatter(
 ccl_device_inline void kernel_path_subsurface_init_indirect(
         ccl_addr_space SubsurfaceIndirectRays *ss_indirect)
 {
-       ss_indirect->tracing = false;
        ss_indirect->num_rays = 0;
 }
 
-ccl_device void kernel_path_subsurface_accum_indirect(
-        ccl_addr_space SubsurfaceIndirectRays *ss_indirect,
-        PathRadiance *L)
-{
-       if(ss_indirect->tracing) {
-               path_radiance_sum_indirect(L);
-               path_radiance_accum_sample(&ss_indirect->direct_L, L);
-               if(ss_indirect->num_rays == 0) {
-                       *L = ss_indirect->direct_L;
-               }
-       }
-}
-
 ccl_device void kernel_path_subsurface_setup_indirect(
         KernelGlobals *kg,
         ccl_addr_space SubsurfaceIndirectRays *ss_indirect,
@@ -157,20 +136,15 @@ ccl_device void kernel_path_subsurface_setup_indirect(
         PathRadiance *L,
         ccl_addr_space float3 *throughput)
 {
-       if(!ss_indirect->tracing) {
-               ss_indirect->direct_L = *L;
-       }
-       ss_indirect->tracing = true;
-
        /* Setup state, ray and throughput for indirect SSS rays. */
        ss_indirect->num_rays--;
 
-       ccl_addr_space Ray *indirect_ray = &ss_indirect->rays[ss_indirect->num_rays];
-       PathRadiance *indirect_L = &ss_indirect->L[ss_indirect->num_rays];
+       path_radiance_sum_indirect(L);
+       path_radiance_reset_indirect(L);
 
        *state = ss_indirect->state[ss_indirect->num_rays];
-       *ray = *indirect_ray;
-       *L = *indirect_L;
+       *ray = ss_indirect->rays[ss_indirect->num_rays];
+       L->state = ss_indirect->L_state[ss_indirect->num_rays];
        *throughput = ss_indirect->throughputs[ss_indirect->num_rays];
 
        state->rng_offset += ss_indirect->num_rays * PRNG_BOUNCE_NUM;
index e798fcc6a2cec2fa5c6b8e630c5d1254fbb1553d..7b566b01b04eba2dceadfa0392e644d57cb09389 100644 (file)
@@ -150,7 +150,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
         int num_samples,
         ccl_addr_space float3 *throughput,
         ccl_addr_space PathState *state,
-        PathRadiance *L,
+        PathRadianceState *L_state,
         ccl_addr_space Ray *ray,
         float sum_sample_weight)
 {
@@ -170,7 +170,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
                return false;
 
        /* modify throughput */
-       path_radiance_bsdf_bounce(L, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
+       path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
 
 #ifdef __DENOISING_FEATURES__
        state->denoising_feature_weight *= sc->sample_weight / (sum_sample_weight * num_samples);
@@ -271,7 +271,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
                                            ShaderData *sd,
                                            ccl_addr_space float3 *throughput,
                                            ccl_addr_space PathState *state,
-                                           PathRadiance *L,
+                                           PathRadianceState *L_state,
                                            ccl_addr_space Ray *ray)
 {
        /* no BSDF? we can stop here */
@@ -292,7 +292,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
                        return false;
 
                /* modify throughput */
-               path_radiance_bsdf_bounce(L, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
+               path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
 
                /* set labels */
                if(!(label & LABEL_TRANSPARENT)) {
index 3cf897ac49ce215677af452fcaa2f0a44fbabca0..b6a856baf2416bd64aae2ecc20ffd8359a5ae92d 100644 (file)
@@ -68,7 +68,7 @@ bool kernel_path_volume_bounce(
     ShaderData *sd,
     ccl_addr_space float3 *throughput,
     ccl_addr_space PathState *state,
-    PathRadiance *L,
+    PathRadianceState *L_state,
     ccl_addr_space Ray *ray)
 {
        /* sample phase function */
@@ -87,7 +87,7 @@ bool kernel_path_volume_bounce(
                return false;
        
        /* modify throughput */
-       path_radiance_bsdf_bounce(L, throughput, &phase_eval, phase_pdf, state->bounce, label);
+       path_radiance_bsdf_bounce(kg, L_state, throughput, &phase_eval, phase_pdf, state->bounce, label);
 
        /* set labels */
        state->ray_pdf = phase_pdf;
index 1853fab19670c55515b3c819e44f7dabce4f4496..cd19d0f90bffe545661682bc1c294ff5b00c947d 100644 (file)
@@ -466,6 +466,18 @@ typedef struct DebugData {
 } DebugData;
 #endif
 
+typedef ccl_addr_space struct PathRadianceState {
+#ifdef __PASSES__
+       float3 diffuse;
+       float3 glossy;
+       float3 transmission;
+       float3 subsurface;
+       float3 scatter;
+
+       float3 direct;
+#endif
+} PathRadianceState;
+
 typedef ccl_addr_space struct PathRadiance {
 #ifdef __PASSES__
        int use_light_pass;
@@ -478,7 +490,6 @@ typedef ccl_addr_space struct PathRadiance {
        float3 ao;
 
        float3 indirect;
-       float3 direct_throughput;
        float3 direct_emission;
 
        float3 color_diffuse;
@@ -499,16 +510,12 @@ typedef ccl_addr_space struct PathRadiance {
        float3 indirect_subsurface;
        float3 indirect_scatter;
 
-       float3 path_diffuse;
-       float3 path_glossy;
-       float3 path_transmission;
-       float3 path_subsurface;
-       float3 path_scatter;
-
        float4 shadow;
        float mist;
 #endif
 
+       PathRadianceState state;
+
 #ifdef __SHADOW_TRICKS__
        /* Total light reachable across the path, ignoring shadow blocked queries. */
        float3 path_total;
@@ -1032,8 +1039,7 @@ typedef struct PathState {
 /* Subsurface */
 
 /* Struct to gather multiple SSS hits. */
-typedef struct SubsurfaceIntersection
-{
+typedef struct SubsurfaceIntersection {
        Ray ray;
        float3 weight[BSSRDF_MAX_HITS];
 
@@ -1043,17 +1049,14 @@ typedef struct SubsurfaceIntersection
 } SubsurfaceIntersection;
 
 /* Struct to gather SSS indirect rays and delay tracing them. */
-typedef struct SubsurfaceIndirectRays
-{
-       bool need_update_volume_stack;
-       bool tracing;
+typedef struct SubsurfaceIndirectRays {
        PathState state[BSSRDF_MAX_HITS];
-       struct PathRadiance direct_L;
 
        int num_rays;
+
        struct Ray rays[BSSRDF_MAX_HITS];
        float3 throughputs[BSSRDF_MAX_HITS];
-       struct PathRadiance L[BSSRDF_MAX_HITS];
+       struct PathRadianceState L_state[BSSRDF_MAX_HITS];
 } SubsurfaceIndirectRays;
 
 /* Constant Kernel Data
index 2c390593ba1458844745167f48c3bc599589076f..2313feac0894c72ee47b07abf1e6f4c25f754655 100644 (file)
@@ -87,7 +87,6 @@ ccl_device_inline bool kernel_split_branched_indirect_start_shared(KernelGlobals
        PathRadiance *inactive_L = &kernel_split_state.path_radiance[inactive_ray];
 
        path_radiance_init(inactive_L, kernel_data.film.use_light_pass);
-       inactive_L->direct_throughput = L->direct_throughput;
        path_radiance_copy_indirect(inactive_L, L);
 
        ray_state[inactive_ray] = RAY_REGENERATED;
@@ -176,7 +175,7 @@ ccl_device_noinline bool kernel_split_branched_path_surface_indirect_light_iter(
                                                                num_samples,
                                                                tp,
                                                                ps,
-                                                               L,
+                                                               &L->state,
                                                                bsdf_ray,
                                                                sum_sample_weight))
                        {
index 2975aa200045de3ee30ea048151b0e276705947d..491487f1230188af8938d7d4aed48951713afdc1 100644 (file)
@@ -65,7 +65,7 @@ ccl_device_noinline bool kernel_split_branched_path_volume_indirect_light_iter(K
                        kernel_path_volume_connect_light(kg, sd, emission_sd, *tp, &branched_state->path_state, L);
 
                        /* indirect light bounce */
-                       if(!kernel_path_volume_bounce(kg, sd, tp, ps, L, pray)) {
+                       if(!kernel_path_volume_bounce(kg, sd, tp, ps, &L->state, pray)) {
                                continue;
                        }
 
@@ -170,7 +170,7 @@ ccl_device void kernel_do_volume(KernelGlobals *kg)
                                                kernel_path_volume_connect_light(kg, sd, emission_sd, *throughput, state, L);
 
                                                /* indirect light bounce */
-                                               if(kernel_path_volume_bounce(kg, sd, throughput, state, L, ray)) {
+                                               if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray)) {
                                                        ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
                                                }
                                                else {
index 82bc2f01fd7f0f42c0b0c58038dad6a6d01af92c..e9fe5552e8cde90fdbd09178c4d5983dda2e8803 100644 (file)
@@ -54,7 +54,6 @@ ccl_device void kernel_indirect_subsurface(KernelGlobals *kg)
 #endif
                if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
                        ccl_addr_space SubsurfaceIndirectRays *ss_indirect = &kernel_split_state.ss_rays[ray_index];
-                       kernel_path_subsurface_accum_indirect(ss_indirect, L);
 
                        /* Trace indirect subsurface rays by restarting the loop. this uses less
                         * stack memory than invoking kernel_path_indirect.
index 4e0c966cca9cdad80c17ada80d1f1dac158b2691..c3373174582acae1f6deaa1d042c2707d36ec4be 100644 (file)
@@ -134,7 +134,7 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
                if(!kernel_data.integrator.branched || IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
 #endif
                        /* Compute direct lighting and next bounce. */
-                       if(!kernel_path_surface_bounce(kg, sd, throughput, state, L, ray)) {
+                       if(!kernel_path_surface_bounce(kg, sd, throughput, state, &L->state, ray)) {
                                kernel_split_path_end(kg, ray_index);
                        }
 #ifdef __BRANCHED_PATH__