diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-03-05 14:05:42 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-03-05 14:21:38 +0300 |
commit | 51e898324de30c0985a80e5bc067358b5ccedbfc (patch) | |
tree | 5efddead1b7ca5655f1d6d2422b59e7da51fe271 /intern/cycles/util | |
parent | 4ccbbd308060f0330472828b317c59e054c9ee7b (diff) |
Adaptive Sampling for Cycles.
This feature takes some inspiration from
"RenderMan: An Advanced Path Tracing Architecture for Movie Rendering" and
"A Hierarchical Automatic Stopping Condition for Monte Carlo Global Illumination"
The basic principle is as follows:
While samples are being added to a pixel, the adaptive sampler writes half
of the samples to a separate buffer. This gives it two separate estimates
of the same pixel, and by comparing their difference it estimates convergence.
Once convergence drops below a given threshold, the pixel is considered done.
When a pixel has not converged yet and needs more samples than the minimum,
its immediate neighbors are also set to take more samples. This is done in order
to more reliably detect sharp features such as caustics. A 3x3 box filter that
is run periodically over the tile buffer is used for that purpose.
After a tile has finished rendering, the values of all passes are scaled as if
they were rendered with the full number of samples. This way, any code operating
on these buffers, for example the denoiser, does not need to be changed for
per-pixel sample counts.
Reviewed By: brecht, #cycles
Differential Revision: https://developer.blender.org/D4686
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_atomic.h | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_types.h | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/intern/cycles/util/util_atomic.h b/intern/cycles/util/util_atomic.h index a8ea1dc925e..13d177d2b25 100644 --- a/intern/cycles/util/util_atomic.h +++ b/intern/cycles/util/util_atomic.h @@ -77,6 +77,7 @@ ccl_device_inline float atomic_compare_and_swap_float(volatile ccl_global float # define atomic_fetch_and_add_uint32(p, x) atomic_add((p), (x)) # define atomic_fetch_and_inc_uint32(p) atomic_inc((p)) # define atomic_fetch_and_dec_uint32(p) atomic_dec((p)) +# define atomic_fetch_and_or_uint32(p, x) atomic_or((p), (x)) # define CCL_LOCAL_MEM_FENCE CLK_LOCAL_MEM_FENCE # define ccl_barrier(flags) barrier(flags) @@ -91,6 +92,7 @@ ccl_device_inline float atomic_compare_and_swap_float(volatile ccl_global float # define atomic_fetch_and_sub_uint32(p, x) atomicSub((unsigned int *)(p), (unsigned int)(x)) # define atomic_fetch_and_inc_uint32(p) atomic_fetch_and_add_uint32((p), 1) # define atomic_fetch_and_dec_uint32(p) atomic_fetch_and_sub_uint32((p), 1) +# define atomic_fetch_and_or_uint32(p, x) atomicOr((unsigned int *)(p), (unsigned int)(x)) ccl_device_inline float atomic_compare_and_swap_float(volatile float *dest, const float old_val, diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index 48e9983ac8f..8a1890ad319 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -101,6 +101,11 @@ ccl_device_inline size_t round_down(size_t x, size_t multiple) return (x / multiple) * multiple; } +ccl_device_inline bool is_power_of_two(size_t x) +{ + return (x & (x - 1)) == 0; +} + CCL_NAMESPACE_END /* Vectorized types declaration. */ |