diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-09-27 04:53:03 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-10-04 22:11:14 +0300 |
commit | 5bb677e592fd5902600f41653a2d56b4d9ae8c56 (patch) | |
tree | 0b03c1e67ec400df23e7ec45ca7e0cc63c1c5ddd /intern/cycles | |
parent | 12f453820514e9478afdda0acf4c4fb1eac11e1c (diff) |
Code refactor: zero render buffers outside of kernel.
This was originally done with the first sample in the kernel for better
performance, but it doesn't work anymore with atomics. Any benefit was
very minor anyway, too small to measure it seems.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/kernel_passes.h | 179 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 3 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_buffer_update.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_data_init.h | 41 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_path_init.h | 5 | ||||
-rw-r--r-- | intern/cycles/render/buffers.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/render/buffers.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/session.cpp | 7 |
9 files changed, 87 insertions, 163 deletions
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index bd756185e78..239598f7dab 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -16,17 +16,17 @@ CCL_NAMESPACE_BEGIN -ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value) +ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, float value) { ccl_global float *buf = buffer; #if defined(__SPLIT_KERNEL__) atomic_add_and_fetch_float(buf, value); #else - *buf = (sample == 0)? value: *buf + value; + *buf += value; #endif /* __SPLIT_KERNEL__ */ } -ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value) +ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, float3 value) { #if defined(__SPLIT_KERNEL__) ccl_global float *buf_x = buffer + 0; @@ -38,11 +38,11 @@ ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sa atomic_add_and_fetch_float(buf_z, value.z); #else ccl_global float3 *buf = (ccl_global float3*)buffer; - *buf = (sample == 0)? value: *buf + value; + *buf += value; #endif /* __SPLIT_KERNEL__ */ } -ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value) +ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, float4 value) { #if defined(__SPLIT_KERNEL__) ccl_global float *buf_x = buffer + 0; @@ -56,35 +56,35 @@ ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sa atomic_add_and_fetch_float(buf_w, value.w); #else ccl_global float4 *buf = (ccl_global float4*)buffer; - *buf = (sample == 0)? value: *buf + value; + *buf += value; #endif /* __SPLIT_KERNEL__ */ } #ifdef __DENOISING_FEATURES__ -ccl_device_inline void kernel_write_pass_float_variance(ccl_global float *buffer, int sample, float value) +ccl_device_inline void kernel_write_pass_float_variance(ccl_global float *buffer, float value) { - kernel_write_pass_float(buffer, sample, value); + kernel_write_pass_float(buffer, value); /* The online one-pass variance update that's used for the megakernel can't easily be implemented * with atomics, so for the split kernel the E[x^2] - 1/N * (E[x])^2 fallback is used. */ - kernel_write_pass_float(buffer+1, sample, value*value); + kernel_write_pass_float(buffer+1, value*value); } # if defined(__SPLIT_KERNEL__) # define kernel_write_pass_float3_unaligned kernel_write_pass_float3 # else -ccl_device_inline void kernel_write_pass_float3_unaligned(ccl_global float *buffer, int sample, float3 value) +ccl_device_inline void kernel_write_pass_float3_unaligned(ccl_global float *buffer, float3 value) { - buffer[0] = (sample == 0)? value.x: buffer[0] + value.x; - buffer[1] = (sample == 0)? value.y: buffer[1] + value.y; - buffer[2] = (sample == 0)? value.z: buffer[2] + value.z; + buffer[0] += value.x; + buffer[1] += value.y; + buffer[2] += value.z; } # endif -ccl_device_inline void kernel_write_pass_float3_variance(ccl_global float *buffer, int sample, float3 value) +ccl_device_inline void kernel_write_pass_float3_variance(ccl_global float *buffer, float3 value) { - kernel_write_pass_float3_unaligned(buffer, sample, value); - kernel_write_pass_float3_unaligned(buffer+3, sample, value*value); + kernel_write_pass_float3_unaligned(buffer, value); + kernel_write_pass_float3_unaligned(buffer+3, value*value); } ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg, ccl_global float *buffer, @@ -98,11 +98,11 @@ ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg, ccl_glob path_total = ensure_finite(path_total); path_total_shaded = ensure_finite(path_total_shaded); - kernel_write_pass_float(buffer, sample/2, path_total); - kernel_write_pass_float(buffer+1, sample/2, path_total_shaded); + kernel_write_pass_float(buffer, path_total); + kernel_write_pass_float(buffer+1, path_total_shaded); float value = path_total_shaded / max(path_total, 1e-7f); - kernel_write_pass_float(buffer+2, sample/2, value*value); + kernel_write_pass_float(buffer+2, value*value); } #endif /* __DENOISING_FEATURES__ */ @@ -163,28 +163,23 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg, #ifdef __KERNEL_DEBUG__ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg, ccl_global float *buffer, - PathRadiance *L, - int sample) + PathRadiance *L) { int flag = kernel_data.film.pass_flag; if(flag & PASS_BVH_TRAVERSED_NODES) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes, - sample, L->debug_data.num_bvh_traversed_nodes); } if(flag & PASS_BVH_TRAVERSED_INSTANCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances, - sample, L->debug_data.num_bvh_traversed_instances); } if(flag & PASS_BVH_INTERSECTIONS) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections, - sample, L->debug_data.num_bvh_intersections); } if(flag & PASS_RAY_BOUNCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces, - sample, L->debug_data.num_ray_bounces); } } @@ -209,35 +204,33 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl kernel_data.film.pass_alpha_threshold == 0.0f || average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) { - int sample = state->sample; - - if(sample == 0) { + if(state->sample == 0) { if(flag & PASS_DEPTH) { float depth = camera_distance(kg, sd->P); - kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth); + kernel_write_pass_float(buffer + kernel_data.film.pass_depth, depth); } if(flag & PASS_OBJECT_ID) { float id = object_pass_id(kg, sd->object); - kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id); + kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, id); } if(flag & PASS_MATERIAL_ID) { float id = shader_pass_id(kg, sd); - kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id); + kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, id); } } if(flag & PASS_NORMAL) { float3 normal = shader_bsdf_average_normal(kg, sd); - kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal); + kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, normal); } if(flag & PASS_UV) { float3 uv = primitive_uv(kg, sd); - kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv); + kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, uv); } if(flag & PASS_MOTION) { float4 speed = primitive_motion_vector(kg, sd); - kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, sample, speed); - kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, sample, 1.0f); + kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, speed); + kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, 1.0f); } state->flag |= PATH_RAY_SINGLE_PASS_DONE; @@ -280,7 +273,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl #endif } -ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample) +ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L) { #ifdef __PASSES__ int flag = kernel_data.film.pass_flag; @@ -289,116 +282,90 @@ ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global f return; if(flag & PASS_DIFFUSE_INDIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, sample, L->indirect_diffuse); + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, L->indirect_diffuse); if(flag & PASS_GLOSSY_INDIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, L->indirect_glossy); + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, L->indirect_glossy); if(flag & PASS_TRANSMISSION_INDIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, L->indirect_transmission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, L->indirect_transmission); if(flag & PASS_SUBSURFACE_INDIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, sample, L->indirect_subsurface); + kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, L->indirect_subsurface); if(flag & PASS_DIFFUSE_DIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, L->direct_diffuse); + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, L->direct_diffuse); if(flag & PASS_GLOSSY_DIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, L->direct_glossy); + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, L->direct_glossy); if(flag & PASS_TRANSMISSION_DIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, L->direct_transmission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, L->direct_transmission); if(flag & PASS_SUBSURFACE_DIRECT) - kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, sample, L->direct_subsurface); + kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, L->direct_subsurface); if(flag & PASS_EMISSION) - kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, L->emission); if(flag & PASS_BACKGROUND) - kernel_write_pass_float3(buffer + kernel_data.film.pass_background, sample, L->background); + kernel_write_pass_float3(buffer + kernel_data.film.pass_background, L->background); if(flag & PASS_AO) - kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, sample, L->ao); + kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, L->ao); if(flag & PASS_DIFFUSE_COLOR) - kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, sample, L->color_diffuse); + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, L->color_diffuse); if(flag & PASS_GLOSSY_COLOR) - kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy); + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, L->color_glossy); if(flag & PASS_TRANSMISSION_COLOR) - kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, L->color_transmission); if(flag & PASS_SUBSURFACE_COLOR) - kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, sample, L->color_subsurface); + kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, L->color_subsurface); if(flag & PASS_SHADOW) { float4 shadow = L->shadow; shadow.w = kernel_data.film.pass_shadow_scale; - kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, sample, shadow); + kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, shadow); } if(flag & PASS_MIST) - kernel_write_pass_float(buffer + kernel_data.film.pass_mist, sample, 1.0f - L->mist); + kernel_write_pass_float(buffer + kernel_data.film.pass_mist, 1.0f - L->mist); #endif } ccl_device_inline void kernel_write_result(KernelGlobals *kg, ccl_global float *buffer, int sample, PathRadiance *L) { - if(L) { - float alpha; - float3 L_sum = path_radiance_clamp_and_sum(kg, L, &alpha); + float alpha; + float3 L_sum = path_radiance_clamp_and_sum(kg, L, &alpha); - kernel_write_pass_float4(buffer, sample, make_float4(L_sum.x, L_sum.y, L_sum.z, alpha)); + kernel_write_pass_float4(buffer, make_float4(L_sum.x, L_sum.y, L_sum.z, alpha)); - kernel_write_light_passes(kg, buffer, L, sample); + kernel_write_light_passes(kg, buffer, L); #ifdef __DENOISING_FEATURES__ - if(kernel_data.film.pass_denoising_data) { + if(kernel_data.film.pass_denoising_data) { # ifdef __SHADOW_TRICKS__ - kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, average(L->path_total), average(L->path_total_shaded)); + kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, average(L->path_total), average(L->path_total_shaded)); # else - kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, 0.0f, 0.0f); + kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, 0.0f, 0.0f); # endif - if(kernel_data.film.pass_denoising_clean) { - float3 noisy, clean; - path_radiance_split_denoising(kg, L, &noisy, &clean); - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, - sample, noisy); - kernel_write_pass_float3_unaligned(buffer + kernel_data.film.pass_denoising_clean, - sample, clean); - } - else { - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, - sample, ensure_finite3(L_sum)); - } - - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL, - sample, L->denoising_normal); - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO, - sample, L->denoising_albedo); - kernel_write_pass_float_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH, - sample, L->denoising_depth); + if(kernel_data.film.pass_denoising_clean) { + float3 noisy, clean; + path_radiance_split_denoising(kg, L, &noisy, &clean); + kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, + noisy); + kernel_write_pass_float3_unaligned(buffer + kernel_data.film.pass_denoising_clean, + clean); } + else { + kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, + ensure_finite3(L_sum)); + } + + kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL, + L->denoising_normal); + kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO, + L->denoising_albedo); + kernel_write_pass_float_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH, + L->denoising_depth); + } #endif /* __DENOISING_FEATURES__ */ #ifdef __KERNEL_DEBUG__ - kernel_write_debug_passes(kg, buffer, L, sample); + kernel_write_debug_passes(kg, buffer, L); #endif - } - else { - kernel_write_pass_float4(buffer, sample, make_float4(0.0f, 0.0f, 0.0f, 0.0f)); - -#ifdef __DENOISING_FEATURES__ - if(kernel_data.film.pass_denoising_data) { - kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, 0.0f, 0.0f); - - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, - sample, make_float3(0.0f, 0.0f, 0.0f)); - - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL, - sample, make_float3(0.0f, 0.0f, 0.0f)); - kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO, - sample, make_float3(0.0f, 0.0f, 0.0f)); - kernel_write_pass_float_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH, - sample, 0.0f); - - if(kernel_data.film.pass_denoising_clean) { - kernel_write_pass_float3_unaligned(buffer + kernel_data.film.pass_denoising_clean, - sample, make_float3(0.0f, 0.0f, 0.0f)); - } - } -#endif /* __DENOISING_FEATURES__ */ - } } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 341ada63ec3..6b6c5603b70 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -688,7 +688,6 @@ ccl_device void kernel_path_trace(KernelGlobals *kg, kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &ray); if(ray.t == 0.0f) { - kernel_write_result(kg, buffer, sample, NULL); return; } diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 70d73a20b97..2597d684a36 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -560,9 +560,6 @@ ccl_device void kernel_branched_path_trace(KernelGlobals *kg, kernel_branched_path_integrate(kg, rng_hash, sample, ray, buffer, &L); kernel_write_result(kg, buffer, sample, &L); } - else { - kernel_write_result(kg, buffer, sample, NULL); - } } #endif /* __SPLIT_KERNEL__ */ diff --git a/intern/cycles/kernel/split/kernel_buffer_update.h b/intern/cycles/kernel/split/kernel_buffer_update.h index 5e9db821f7b..511334e0550 100644 --- a/intern/cycles/kernel/split/kernel_buffer_update.h +++ b/intern/cycles/kernel/split/kernel_buffer_update.h @@ -110,7 +110,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg, /* Store buffer offset for writing to passes. */ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride; - ccl_global float *buffer = tile->buffer + buffer_offset; kernel_split_state.buffer_offset[ray_index] = buffer_offset; /* Initialize random numbers and ray. */ @@ -131,11 +130,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg, enqueue_flag = 1; } else { - /* These rays do not participate in path-iteration. */ - float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f); - /* Accumulate result in output buffer. */ - kernel_write_pass_float4(buffer, sample, L_rad); - ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE); } } diff --git a/intern/cycles/kernel/split/kernel_data_init.h b/intern/cycles/kernel/split/kernel_data_init.h index f4df949fdb1..77fb61b80a8 100644 --- a/intern/cycles/kernel/split/kernel_data_init.h +++ b/intern/cycles/kernel/split/kernel_data_init.h @@ -23,22 +23,6 @@ CCL_NAMESPACE_BEGIN * The number of elements in the queues is initialized to 0; */ -/* Distributes an amount of work across all threads - * note: work done inside the loop may not show up to all threads till after - * the current kernel has completed - */ -#define parallel_for(kg, iter_name, work_size) \ - for(size_t _size = (work_size), \ - _global_size = ccl_global_size(0) * ccl_global_size(1), \ - _n = _size / _global_size, \ - _thread = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0), \ - iter_name = (_n > 0) ? (_thread * _n) : (_thread) \ - ; \ - (iter_name < (_thread+1) * _n) || (iter_name == _n * _global_size + _thread && _thread < _size % _global_size) \ - ; \ - iter_name = (iter_name != (_thread+1) * _n - 1) ? (iter_name + 1) : (_n * _global_size + _thread) \ - ) - #ifndef __KERNEL_CPU__ ccl_device void kernel_data_init( #else @@ -119,31 +103,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( */ *use_queues_flag = 0; } - - /* zero the tiles pixels if this is the first sample */ - if(start_sample == 0) { - int pass_stride = kernel_data.film.pass_stride; - -#ifdef __KERNEL_CPU__ - for(int y = sy; y < sy + sh; y++) { - int index = offset + y * stride; - memset(buffer + (sx + index) * pass_stride, 0, sizeof(float) * pass_stride * sw); - } -#else - parallel_for(kg, i, sw * sh * pass_stride) { - int pixel = i / pass_stride; - int pass = i % pass_stride; - - int x = sx + pixel % sw; - int y = sy + pixel / sw; - - int index = (offset + x + y*stride) * pass_stride + pass; - - *(buffer + index) = 0.0f; - } -#endif - } - #endif /* KERENL_STUB */ } diff --git a/intern/cycles/kernel/split/kernel_path_init.h b/intern/cycles/kernel/split/kernel_path_init.h index 1bd641b031d..5ad62b585fe 100644 --- a/intern/cycles/kernel/split/kernel_path_init.h +++ b/intern/cycles/kernel/split/kernel_path_init.h @@ -47,7 +47,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) { /* Store buffer offset for writing to passes. */ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride; - ccl_global float *buffer = tile->buffer + buffer_offset; kernel_split_state.buffer_offset[ray_index] = buffer_offset; /* Initialize random numbers and ray. */ @@ -75,10 +74,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) { #endif } else { - /* These rays do not participate in path-iteration. */ - float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f); - /* Accumulate result in output buffer. */ - kernel_write_pass_float4(buffer, sample, L_rad); ASSIGN_RAY_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE); } } diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index cf66e5385c9..98c7ff8ce14 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -145,6 +145,13 @@ void RenderBuffers::reset(Device *device, BufferParams& params_) device->mem_zero(buffer); } +void RenderBuffers::zero(Device *device) +{ + if(buffer.device_pointer) { + device->mem_zero(buffer); + } +} + bool RenderBuffers::copy_from_device(Device *from_device) { if(!buffer.device_pointer) diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index 552dabe178a..2780fc8a68d 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -81,6 +81,7 @@ public: ~RenderBuffers(); void reset(Device *device, BufferParams& params); + void zero(Device *device); bool copy_from_device(Device *from_device = NULL); bool get_pass_rect(PassType type, float exposure, int sample, int components, float *pixels); diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 69cfb5c3e6e..f1ff6b49b71 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -970,7 +970,12 @@ void Session::update_status_time(bool show_pause, bool show_done) void Session::render() { - /* add path trace task */ + /* Clear buffers. */ + if(buffers && tile_manager.state.sample == 0) { + buffers->zero(device); + } + + /* Add path trace task. */ DeviceTask task(DeviceTask::RENDER); task.acquire_tile = function_bind(&Session::acquire_tile, this, _1, _2); |