[Bf-blender-cvs] [4e68f48] master: Cycles: Initialize the RNG state from the kernel instead of the host
Lukas Stockner
noreply at git.blender.org
Sun Oct 30 11:51:26 CET 2016
Commit: 4e68f48227e228fbf75736005ceed4cf1cb55215
Author: Lukas Stockner
Date: Sun Oct 30 00:56:39 2016 +0200
Branches: master
https://developer.blender.org/rB4e68f48227e228fbf75736005ceed4cf1cb55215
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
===================================================================
M intern/cycles/kernel/CMakeLists.txt
M intern/cycles/kernel/kernel_path_common.h
M intern/cycles/render/buffers.cpp
M intern/cycles/util/util_hash.h
===================================================================
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 694f19a..56bcafb 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 1912dfa..13597ea 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 1e170d3..cb20e81 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 3ff2802..98c3a68 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
More information about the Bf-blender-cvs
mailing list