Possible fix for #35198: uninitialized memory access with background multiple
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 3 May 2013 05:24:05 +0000 (05:24 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 3 May 2013 05:24:05 +0000 (05:24 +0000)
importance sampling + OSL.

intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_path.h

index 7d7494657e2cbad40b3047842b5238602d2bdfb4..0553ac7a4eebddc9d0248a6e6c2c5715a065e4b7 100644 (file)
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
 /* Direction Emission */
 
 __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
-       LightSample *ls, float u, float v, float3 I, float t, float time)
+       LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time)
 {
        /* setup shading at emitter */
        ShaderData sd;
@@ -38,6 +38,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
 #endif
                ray.dP.dx = make_float3(0.0f, 0.0f, 0.0f);
                ray.dP.dy = make_float3(0.0f, 0.0f, 0.0f);
+               ray.dD = dI;
 #ifdef __CAMERA_MOTION__
                ray.time = time;
 #endif
@@ -93,8 +94,13 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
        if(ls.pdf == 0.0f)
                return false;
 
+       /* todo: implement */
+       differential3 dD;
+       dD.dx = make_float3(0.0f, 0.0f, 0.0f);
+       dD.dy = make_float3(0.0f, 0.0f, 0.0f);
+
        /* evaluate closure */
-       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D, ls.t, sd->time);
+       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D, dD, ls.t, sd->time);
 
        if(is_zero(light_eval))
                return false;
@@ -183,7 +189,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
        /* todo: missing texture coordinates */
        float u = 0.0f;
        float v = 0.0f;
-       float3 L = direct_emissive_eval(kg, 0.0f, &ls, u, v, -ray->D, ls.t, ray->time);
+       float3 L = direct_emissive_eval(kg, 0.0f, &ls, u, v, -ray->D, ray->dD, ls.t, ray->time);
 
        if(!(path_flag & PATH_RAY_MIS_SKIP)) {
                /* multiple importance sampling, get regular light pdf,
index 956125078d960a84e9c11089ddf9bc09a0a15253..4e50b84291a1ac3940f6c73fd072bf28ce8941b7 100644 (file)
@@ -280,6 +280,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                        light_ray.D = ray.D;
                        light_ray.t = ray_t;
                        light_ray.time = ray.time;
+                       light_ray.dD = ray.dD;
+                       light_ray.dP = ray.dP;
 
                        /* intersect with lamp */
                        float light_t = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT);
@@ -536,6 +538,8 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                        light_ray.D = ray.D;
                        light_ray.t = ray_t;
                        light_ray.time = ray.time;
+                       light_ray.dD = ray.dD;
+                       light_ray.dP = ray.dP;
 
                        /* intersect with lamp */
                        float light_t = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT);