diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-30 01:56:39 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-30 13:51:20 +0300 |
commit | 4e68f48227e228fbf75736005ceed4cf1cb55215 (patch) | |
tree | 5bc3cf3e92d1b63714055cabd3d73eb971d1bcaa | |
parent | 26bf230920cb9ca0aa9626430169967f9e120482 (diff) |
Cycles: Initialize the RNG state from the kernel instead of the host
This allows to save a memory copy, which will be particularly useful for network rendering.
Reviewers: sergey, brecht, dingto, juicyfruit, maiself
Differential Revision: https://developer.blender.org/D2323
-rw-r--r-- | intern/cycles/kernel/CMakeLists.txt | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_common.h | 6 | ||||
-rw-r--r-- | intern/cycles/render/buffers.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/util/util_hash.h | 6 |
4 files changed, 11 insertions, 10 deletions
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 694f19a808a..56bcafbce38 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -177,6 +177,7 @@ set(SRC_UTIL_HEADERS ../util/util_atomic.h ../util/util_color.h ../util/util_half.h + ../util/util_hash.h ../util/util_math.h ../util/util_math_fast.h ../util/util_static_assert.h diff --git a/intern/cycles/kernel/kernel_path_common.h b/intern/cycles/kernel/kernel_path_common.h index 1912dfa16ed..13597eab287 100644 --- a/intern/cycles/kernel/kernel_path_common.h +++ b/intern/cycles/kernel/kernel_path_common.h @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "util_hash.h" + CCL_NAMESPACE_BEGIN ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, @@ -28,6 +30,10 @@ ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, int num_samples = kernel_data.integrator.aa_samples; + if(sample == 0) { + *rng_state = hash_int_2d(x, y); + } + path_rng_init(kg, rng_state, sample, num_samples, rng, x, y, &filter_u, &filter_v); /* sample camera ray */ diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 1e170d3a96e..cb20e811708 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -135,15 +135,7 @@ void RenderBuffers::reset(Device *device, BufferParams& params_) /* allocate rng state */ rng_state.resize(params.width, params.height); - uint *init_state = rng_state.resize(params.width, params.height); - int x, y, width = params.width, height = params.height; - - for(y = 0; y < height; y++) - for(x = 0; x < width; x++) - init_state[y*width + x] = hash_int_2d(params.full_x+x, params.full_y+y); - device->mem_alloc(rng_state, MEM_READ_WRITE); - device->mem_copy_to(rng_state); } bool RenderBuffers::copy_from_device() diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h index 3ff2802b46d..98c3a681ff2 100644 --- a/intern/cycles/util/util_hash.h +++ b/intern/cycles/util/util_hash.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN -static inline uint hash_int_2d(uint kx, uint ky) +ccl_device_inline uint hash_int_2d(uint kx, uint ky) { #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) @@ -44,11 +44,12 @@ static inline uint hash_int_2d(uint kx, uint ky) #undef rot } -static inline uint hash_int(uint k) +ccl_device_inline uint hash_int(uint k) { return hash_int_2d(k, 0); } +#ifndef __KERNEL_GPU__ static inline uint hash_string(const char *str) { uint i = 0, c; @@ -58,6 +59,7 @@ static inline uint hash_string(const char *str) return i; } +#endif CCL_NAMESPACE_END |