diff options
Diffstat (limited to 'intern/cycles/kernel/kernel_path.h')
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 84 |
1 files changed, 58 insertions, 26 deletions
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 2806296ba93..48df60162b1 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -1134,20 +1134,8 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam #endif -__device void kernel_path_trace(KernelGlobals *kg, - __global float *buffer, __global uint *rng_state, - int sample, int x, int y, int offset, int stride) +__device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray) { - /* buffer offset */ - int index = offset + x + y*stride; - int pass_stride = kernel_data.film.pass_stride; - - rng_state += index; - buffer += index*pass_stride; - - /* initialize random numbers */ - RNG rng; - float filter_u; float filter_v; #ifdef __CMJ__ @@ -1156,38 +1144,82 @@ __device void kernel_path_trace(KernelGlobals *kg, int num_samples = 0; #endif - path_rng_init(kg, rng_state, sample, num_samples, &rng, x, y, &filter_u, &filter_v); + path_rng_init(kg, rng_state, sample, num_samples, rng, x, y, &filter_u, &filter_v); /* sample camera ray */ - Ray ray; float lens_u = 0.0f, lens_v = 0.0f; if(kernel_data.cam.aperturesize > 0.0f) - path_rng_2D(kg, &rng, sample, num_samples, PRNG_LENS_U, &lens_u, &lens_v); + path_rng_2D(kg, rng, sample, num_samples, PRNG_LENS_U, &lens_u, &lens_v); float time = 0.0f; #ifdef __CAMERA_MOTION__ if(kernel_data.cam.shuttertime != -1.0f) - time = path_rng_1D(kg, &rng, sample, num_samples, PRNG_TIME); + time = path_rng_1D(kg, rng, sample, num_samples, PRNG_TIME); #endif - camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, &ray); + camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray); +} + +__device void kernel_path_trace_progressive(KernelGlobals *kg, + __global float *buffer, __global uint *rng_state, + int sample, int x, int y, int offset, int stride) +{ + /* buffer offset */ + int index = offset + x + y*stride; + int pass_stride = kernel_data.film.pass_stride; + + rng_state += index; + buffer += index*pass_stride; + + /* initialize random numbers and ray */ + RNG rng; + Ray ray; + + kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray); /* integrate */ float4 L; - if (ray.t != 0.0f) { -#ifdef __NON_PROGRESSIVE__ - if(kernel_data.integrator.progressive) -#endif - L = kernel_path_progressive(kg, &rng, sample, ray, buffer); + if (ray.t != 0.0f) + L = kernel_path_progressive(kg, &rng, sample, ray, buffer); + else + L = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + + /* accumulate result in output buffer */ + kernel_write_pass_float4(buffer, sample, L); + + path_rng_end(kg, rng_state, rng); +} + +__device void kernel_path_trace_non_progressive(KernelGlobals *kg, + __global float *buffer, __global uint *rng_state, + int sample, int x, int y, int offset, int stride) +{ + /* buffer offset */ + int index = offset + x + y*stride; + int pass_stride = kernel_data.film.pass_stride; + + rng_state += index; + buffer += index*pass_stride; + + /* initialize random numbers and ray */ + RNG rng; + Ray ray; + + kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray); + + /* integrate */ + float4 L; + + if (ray.t != 0.0f) #ifdef __NON_PROGRESSIVE__ - else - L = kernel_path_non_progressive(kg, &rng, sample, ray, buffer); + L = kernel_path_non_progressive(kg, &rng, sample, ray, buffer); +#else + L = kernel_path_progressive(kg, &rng, sample, ray, buffer); #endif - } else L = make_float4(0.0f, 0.0f, 0.0f, 0.0f); |