diff options
Diffstat (limited to 'intern/cycles/device/device_task.cpp')
-rw-r--r-- | intern/cycles/device/device_task.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp index 376ad06a734..c36b1344c3b 100644 --- a/intern/cycles/device/device_task.cpp +++ b/intern/cycles/device/device_task.cpp @@ -115,7 +115,7 @@ void DeviceTask::split(list<DeviceTask> &tasks, int num, int max_size) void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples) { - if ((type != RENDER) && (type != SHADER)) + if (type == FILM_CONVERT) return; if (update_progress_sample) { @@ -136,4 +136,59 @@ void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples) } } +/* Adaptive Sampling */ + +AdaptiveSampling::AdaptiveSampling() + : use(true), adaptive_step(ADAPTIVE_SAMPLE_STEP), min_samples(0) +{ +} + +/* Render samples in steps that align with the adaptive filtering. */ +int AdaptiveSampling::align_static_samples(int samples) const +{ + if (samples > adaptive_step) { + /* Make multiple of adaptive_step. */ + while (samples % adaptive_step != 0) { + samples--; + } + } + else if (samples < adaptive_step) { + /* Make divisor of adaptive_step. */ + while (adaptive_step % samples != 0) { + samples--; + } + } + + return max(samples, 1); +} + +/* Render samples in steps that align with the adaptive filtering, with the + * suggested number of samples dynamically changing. */ +int AdaptiveSampling::align_dynamic_samples(int offset, int samples) const +{ + /* Round so that we end up on multiples of adaptive_samples. */ + samples += offset; + + if (samples > adaptive_step) { + /* Make multiple of adaptive_step. */ + while (samples % adaptive_step != 0) { + samples--; + } + } + + samples -= offset; + + return max(samples, 1); +} + +bool AdaptiveSampling::need_filter(int sample) const +{ + if (sample > min_samples) { + return (sample & (adaptive_step - 1)) == (adaptive_step - 1); + } + else { + return false; + } +} + CCL_NAMESPACE_END |