From e3e16cecc4f080edbbd14e4bf1cfc580c5957d62 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 Sep 2017 00:39:53 +0200 Subject: Code refactor: remove rng_state buffer and compute hash on the fly. A little faster on some benchmark scenes, a little slower on others, seems about performance neutral on average and saves a little memory. --- intern/cycles/kernel/split/kernel_buffer_update.h | 6 +----- intern/cycles/kernel/split/kernel_data_init.h | 15 +-------------- intern/cycles/kernel/split/kernel_path_init.h | 5 ----- 3 files changed, 2 insertions(+), 24 deletions(-) (limited to 'intern/cycles/kernel/split') diff --git a/intern/cycles/kernel/split/kernel_buffer_update.h b/intern/cycles/kernel/split/kernel_buffer_update.h index e8547767480..5e9db821f7b 100644 --- a/intern/cycles/kernel/split/kernel_buffer_update.h +++ b/intern/cycles/kernel/split/kernel_buffer_update.h @@ -108,10 +108,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg, uint x, y, sample; get_work_pixel(tile, work_index, &x, &y, &sample); - /* Remap rng_state to current pixel. */ - ccl_global uint *rng_state = kernel_split_params.tile.rng_state; - rng_state += tile->offset + x + y*tile->stride; - /* Store buffer offset for writing to passes. */ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride; ccl_global float *buffer = tile->buffer + buffer_offset; @@ -119,7 +115,7 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg, /* Initialize random numbers and ray. */ uint rng_hash; - kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng_hash, ray); + kernel_path_trace_setup(kg, sample, x, y, &rng_hash, ray); if(ray->t != 0.0f) { /* Initialize throughput, path radiance, Ray, PathState; diff --git a/intern/cycles/kernel/split/kernel_data_init.h b/intern/cycles/kernel/split/kernel_data_init.h index 2da3ca47466..f4df949fdb1 100644 --- a/intern/cycles/kernel/split/kernel_data_init.h +++ b/intern/cycles/kernel/split/kernel_data_init.h @@ -49,7 +49,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( ccl_global void *split_data_buffer, int num_elements, ccl_global char *ray_state, - ccl_global uint *rng_state, #ifdef __KERNEL_OPENCL__ KERNEL_BUFFER_PARAMS, @@ -84,7 +83,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( kernel_split_params.tile.offset = offset; kernel_split_params.tile.stride = stride; - kernel_split_params.tile.rng_state = rng_state; kernel_split_params.tile.buffer = buffer; kernel_split_params.total_work_size = sw * sh * num_samples; @@ -122,7 +120,7 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( *use_queues_flag = 0; } - /* zero the tiles pixels and initialize rng_state if this is the first sample */ + /* zero the tiles pixels if this is the first sample */ if(start_sample == 0) { int pass_stride = kernel_data.film.pass_stride; @@ -130,9 +128,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( for(int y = sy; y < sy + sh; y++) { int index = offset + y * stride; memset(buffer + (sx + index) * pass_stride, 0, sizeof(float) * pass_stride * sw); - for(int x = sx; x < sx + sw; x++) { - rng_state[index + x] = hash_int_2d(x, y); - } } #else parallel_for(kg, i, sw * sh * pass_stride) { @@ -146,14 +141,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( *(buffer + index) = 0.0f; } - - parallel_for(kg, i, sw * sh) { - int x = sx + i % sw; - int y = sy + i / sw; - - int index = (offset + x + y*stride); - *(rng_state + index) = hash_int_2d(x, y); - } #endif } diff --git a/intern/cycles/kernel/split/kernel_path_init.h b/intern/cycles/kernel/split/kernel_path_init.h index 701d39403ad..1bd641b031d 100644 --- a/intern/cycles/kernel/split/kernel_path_init.h +++ b/intern/cycles/kernel/split/kernel_path_init.h @@ -45,10 +45,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) { uint x, y, sample; get_work_pixel(tile, work_index, &x, &y, &sample); - /* Remap rng_state and buffer to current pixel. */ - ccl_global uint *rng_state = kernel_split_params.tile.rng_state; - rng_state += tile->offset + x + y*tile->stride; - /* Store buffer offset for writing to passes. */ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride; ccl_global float *buffer = tile->buffer + buffer_offset; @@ -57,7 +53,6 @@ ccl_device void kernel_path_init(KernelGlobals *kg) { /* Initialize random numbers and ray. */ uint rng_hash; kernel_path_trace_setup(kg, - rng_state, sample, x, y, &rng_hash, -- cgit v1.2.3