diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2018-07-04 15:02:38 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2018-07-04 15:38:03 +0300 |
commit | c9608047472ae2b08d2d4b188fca5211a6c0b925 (patch) | |
tree | 171bc5203f26edf51f0cdc2dc22d33e8b05725bb /intern/cycles/device/opencl | |
parent | f1525cf53462b5841f2f50283ae2926ab990170e (diff) |
Cycles Denoising: Pass tile buffers to every OpenCL kernel to conform to standard and get rid of set_tile_info
Diffstat (limited to 'intern/cycles/device/opencl')
-rw-r--r-- | intern/cycles/device/opencl/opencl.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_base.cpp | 48 |
2 files changed, 20 insertions, 30 deletions
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index c550d738bd5..22e0503365c 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -436,8 +436,6 @@ protected: device_ptr depth_ptr, device_ptr output_ptr, DenoisingTask *task); - bool denoising_set_tile_info(device_ptr *buffers, - DenoisingTask *task); device_ptr mem_alloc_sub_ptr(device_memory& mem, int offset, int size); void mem_free_sub_ptr(device_ptr ptr); diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 50d371e4c55..9a50d217321 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -246,7 +246,6 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea denoising_program.add_kernel(ustring("filter_nlm_normalize")); denoising_program.add_kernel(ustring("filter_nlm_construct_gramian")); denoising_program.add_kernel(ustring("filter_finalize")); - denoising_program.add_kernel(ustring("filter_set_tile_info")); vector<OpenCLProgram*> programs; programs.push_back(&base_program); @@ -981,9 +980,16 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr, cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow")); - kernel_set_args(ckFilterDivideShadow, 0, - task->render_buffer.samples, - tile_info_mem, + int arg_ofs = kernel_set_args(ckFilterDivideShadow, 0, + task->render_buffer.samples, + tile_info_mem); + cl_mem buffers[9]; + for(int i = 0; i < 9; i++) { + buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]); + arg_ofs += kernel_set_args(ckFilterDivideShadow, arg_ofs, + buffers[i]); + } + kernel_set_args(ckFilterDivideShadow, arg_ofs, a_mem, b_mem, sample_variance_mem, @@ -1012,9 +1018,16 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset, cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature")); - kernel_set_args(ckFilterGetFeature, 0, - task->render_buffer.samples, - tile_info_mem, + int arg_ofs = kernel_set_args(ckFilterGetFeature, 0, + task->render_buffer.samples, + tile_info_mem); + cl_mem buffers[9]; + for(int i = 0; i < 9; i++) { + buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]); + arg_ofs += kernel_set_args(ckFilterGetFeature, arg_ofs, + buffers[i]); + } + kernel_set_args(ckFilterGetFeature, arg_ofs, mean_offset, variance_offset, mean_mem, @@ -1056,29 +1069,8 @@ bool OpenCLDeviceBase::denoising_detect_outliers(device_ptr image_ptr, return true; } -bool OpenCLDeviceBase::denoising_set_tile_info(device_ptr *buffers, - DenoisingTask *task) -{ - task->tile_info_mem.copy_to_device(); - - cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer); - - cl_kernel ckFilterSetTileInfo = denoising_program(ustring("filter_set_tile_info")); - - kernel_set_args(ckFilterSetTileInfo, 0, tile_info_mem); - for(int i = 0; i < 9; i++) { - cl_mem buffer_mem = CL_MEM_PTR(buffers[i]); - kernel_set_args(ckFilterSetTileInfo, i+1, buffer_mem); - } - - enqueue_kernel(ckFilterSetTileInfo, 1, 1); - - return true; -} - void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising) { - denoising.functions.set_tile_info = function_bind(&OpenCLDeviceBase::denoising_set_tile_info, this, _1, &denoising); denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising); denoising.functions.reconstruct = function_bind(&OpenCLDeviceBase::denoising_reconstruct, this, _1, _2, _3, &denoising); denoising.functions.divide_shadow = function_bind(&OpenCLDeviceBase::denoising_divide_shadow, this, _1, _2, _3, _4, _5, &denoising); |