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
This commit is contained in:
@@ -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
|
||||
|
@@ -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 */
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user