Fix T60300: Cycles SSS render hanging with AMD OpenCL.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 8 Jan 2019 14:35:54 +0000 (15:35 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 8 Jan 2019 14:37:16 +0000 (15:37 +0100)
intern/cycles/kernel/split/kernel_subsurface_scatter.h

index c51246f..08769fe 100644 (file)
@@ -47,6 +47,11 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
                if(!CLOSURE_IS_BSSRDF(sc->type))
                        continue;
 
+               /* Closure memory will be overwritten, so read required variables now. */
+               Bssrdf *bssrdf = (Bssrdf *)sc;
+               ClosureType bssrdf_type = sc->type;
+               float bssrdf_roughness = bssrdf->roughness;
+
                /* set up random number generator */
                if(branched_state->ss_next_sample == 0 && branched_state->next_hit == 0 &&
                   branched_state->next_closure == 0 && branched_state->next_sample == 0)
@@ -110,10 +115,6 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
                                *bssrdf_sd = *sd; /* note: copy happens each iteration of inner loop, this is
                                                   * important as the indirect path will write into bssrdf_sd */
 
-                               Bssrdf *bssrdf = (Bssrdf *)sc;
-                               ClosureType bssrdf_type = sc->type;
-                               float bssrdf_roughness = bssrdf->roughness;
-
                                LocalIntersection ss_isect_private = *ss_isect;
                                subsurface_scatter_multi_setup(kg,
                                                               &ss_isect_private,