Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_adaptive_sampling.h
| Show All 16 Lines | |||||
| #pragma once | #pragma once | ||||
| #include "kernel/kernel_write_passes.h" | #include "kernel/kernel_write_passes.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Check whether the pixel has converged and should not be sampled anymore. */ | /* Check whether the pixel has converged and should not be sampled anymore. */ | ||||
| ccl_device_forceinline bool kernel_need_sample_pixel(INTEGRATOR_STATE_CONST_ARGS, | ccl_device_forceinline bool kernel_need_sample_pixel(KernelGlobals kg, | ||||
| ConstIntegratorState state, | |||||
| ccl_global float *render_buffer) | ccl_global float *render_buffer) | ||||
| { | { | ||||
| if (kernel_data.film.pass_adaptive_aux_buffer == PASS_UNUSED) { | if (kernel_data.film.pass_adaptive_aux_buffer == PASS_UNUSED) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| const uint32_t render_pixel_index = INTEGRATOR_STATE(path, render_pixel_index); | const uint32_t render_pixel_index = INTEGRATOR_STATE(state, path, render_pixel_index); | ||||
| const uint64_t render_buffer_offset = (uint64_t)render_pixel_index * | const uint64_t render_buffer_offset = (uint64_t)render_pixel_index * | ||||
| kernel_data.film.pass_stride; | kernel_data.film.pass_stride; | ||||
| ccl_global float *buffer = render_buffer + render_buffer_offset; | ccl_global float *buffer = render_buffer + render_buffer_offset; | ||||
| const uint aux_w_offset = kernel_data.film.pass_adaptive_aux_buffer + 3; | const uint aux_w_offset = kernel_data.film.pass_adaptive_aux_buffer + 3; | ||||
| return buffer[aux_w_offset] == 0.0f; | return buffer[aux_w_offset] == 0.0f; | ||||
| } | } | ||||
| /* Determines whether to continue sampling a given pixel or if it has sufficiently converged. */ | /* Determines whether to continue sampling a given pixel or if it has sufficiently converged. */ | ||||
| ccl_device bool kernel_adaptive_sampling_convergence_check(ccl_global const KernelGlobals *kg, | ccl_device bool kernel_adaptive_sampling_convergence_check(KernelGlobals kg, | ||||
| ccl_global float *render_buffer, | ccl_global float *render_buffer, | ||||
| int x, | int x, | ||||
| int y, | int y, | ||||
| float threshold, | float threshold, | ||||
| bool reset, | bool reset, | ||||
| int offset, | int offset, | ||||
| int stride) | int stride) | ||||
| { | { | ||||
| Show All 33 Lines | ccl_device bool kernel_adaptive_sampling_convergence_check(KernelGlobals kg, | ||||
| buffer[aux_w_offset] = did_converge; | buffer[aux_w_offset] = did_converge; | ||||
| return did_converge; | return did_converge; | ||||
| } | } | ||||
| /* This is a simple box filter in two passes. | /* This is a simple box filter in two passes. | ||||
| * When a pixel demands more adaptive samples, let its neighboring pixels draw more samples too. */ | * When a pixel demands more adaptive samples, let its neighboring pixels draw more samples too. */ | ||||
| ccl_device void kernel_adaptive_sampling_filter_x(ccl_global const KernelGlobals *kg, | ccl_device void kernel_adaptive_sampling_filter_x(KernelGlobals kg, | ||||
| ccl_global float *render_buffer, | ccl_global float *render_buffer, | ||||
| int y, | int y, | ||||
| int start_x, | int start_x, | ||||
| int width, | int width, | ||||
| int offset, | int offset, | ||||
| int stride) | int stride) | ||||
| { | { | ||||
| kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); | kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); | ||||
| Show All 16 Lines | else { | ||||
| if (prev) { | if (prev) { | ||||
| buffer[aux_w_offset] = 0.0f; | buffer[aux_w_offset] = 0.0f; | ||||
| } | } | ||||
| prev = false; | prev = false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void kernel_adaptive_sampling_filter_y(ccl_global const KernelGlobals *kg, | ccl_device void kernel_adaptive_sampling_filter_y(KernelGlobals kg, | ||||
| ccl_global float *render_buffer, | ccl_global float *render_buffer, | ||||
| int x, | int x, | ||||
| int start_y, | int start_y, | ||||
| int height, | int height, | ||||
| int offset, | int offset, | ||||
| int stride) | int stride) | ||||
| { | { | ||||
| kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); | kernel_assert(kernel_data.film.pass_adaptive_aux_buffer != PASS_UNUSED); | ||||
| Show All 25 Lines | |||||