diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2018-10-06 21:39:01 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2018-10-06 22:49:54 +0300 |
commit | a0cc7bd961ef2cd501468dce08998992a88b3bed (patch) | |
tree | 90a26871e42e7aafc7d17c0172b4513a501896f8 /intern/cycles/device | |
parent | 6e08b01bd9ab87f63d8176bf2ec0b4f073a92ee3 (diff) |
Cycles: Implement vectorized NLM kernels for faster CPU denoising
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/device/device_denoising.cpp | 10 |
2 files changed, 14 insertions, 8 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 7c72ab1a009..4986bb809fb 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -184,11 +184,11 @@ public: KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel; KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel; - KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel; - KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_blur_kernel; - KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_calc_weight_kernel; - KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int, int)> filter_nlm_update_output_kernel; - KernelFunctions<void(*)(float*, float*, int*, int)> filter_nlm_normalize_kernel; + KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel; + KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_blur_kernel; + KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_calc_weight_kernel; + KernelFunctions<void(*)(int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_nlm_update_output_kernel; + KernelFunctions<void(*)(float*, float*, int*, int)> filter_nlm_normalize_kernel; KernelFunctions<void(*)(float*, int, int, int, float*, int*, int*, int, int, float)> filter_construct_transform_kernel; KernelFunctions<void(*)(int, int, float*, float*, float*, int*, float*, float3*, int*, int*, int, int, int)> filter_nlm_construct_gramian_kernel; @@ -475,6 +475,7 @@ public: float *blurDifference = temporary_mem; float *difference = temporary_mem + task->buffer.pass_stride; float *weightAccum = temporary_mem + 2*task->buffer.pass_stride; + float *temp_image = temporary_mem + 3*task->buffer.pass_stride; memset(weightAccum, 0, sizeof(float)*w*h); memset((float*) out_ptr, 0, sizeof(float)*w*h); @@ -499,6 +500,7 @@ public: filter_nlm_update_output_kernel()(dx, dy, blurDifference, (float*) image_ptr, + temp_image, (float*) out_ptr, weightAccum, local_rect, diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index 23c18fa15b2..3384e1d81fd 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -99,14 +99,18 @@ void DenoisingTask::setup_denoising_buffer() buffer.mem.alloc_to_device(mem_size, false); /* CPUs process shifts sequentially while GPUs process them in parallel. */ - int num_shifts = 1; + int num_layers; if(buffer.gpu_temporary_mem) { /* Shadowing prefiltering uses a radius of 6, so allocate at least that much. */ int max_radius = max(radius, 6); - num_shifts = (2*max_radius + 1) * (2*max_radius + 1); + int num_shifts = (2*max_radius + 1) * (2*max_radius + 1); + num_layers = 2*num_shifts + 1; + } + else { + num_layers = 4; } /* Allocate two layers per shift as well as one for the weight accumulation. */ - buffer.temporary_mem.alloc_to_device((2*num_shifts + 1) * buffer.pass_stride); + buffer.temporary_mem.alloc_to_device(num_layers * buffer.pass_stride); } void DenoisingTask::prefilter_shadowing() |