[Bf-blender-cvs] [6389471c40d] master: Fix NLM denoiser no longer working with OptiX after recent commit

Patrick Mours noreply at git.blender.org
Wed Feb 12 15:49:36 CET 2020


Commit: 6389471c40d41c79ce633449756cd684261e1d64
Author: Patrick Mours
Date:   Wed Feb 12 15:36:12 2020 +0100
Branches: master
https://developer.blender.org/rB6389471c40d41c79ce633449756cd684261e1d64

Fix NLM denoiser no longer working with OptiX after recent commit

===================================================================

M	intern/cycles/device/device_optix.cpp

===================================================================

diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index 4a711c50731..adb0f60a006 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -659,8 +659,10 @@ class OptiXDevice : public CUDADevice {
 
   bool launch_denoise(DeviceTask &task, RenderTile &rtile, int thread_index)
   {
-    int total_samples = rtile.start_sample + rtile.num_samples;
+    // Update current sample (for display and NLM denoising task)
+    rtile.sample = rtile.start_sample + rtile.num_samples;
 
+    // Make CUDA context current now, since it is used for both denoising tasks
     const CUDAContextScope scope(cuContext);
 
     // Choose between OptiX and NLM denoising
@@ -770,7 +772,7 @@ class OptiXDevice : public CUDADevice {
                         &task.pass_stride,
                         const_cast<int *>(pass_offset),
                         &task.denoising.optix_input_passes,
-                        &total_samples};
+                        &rtile.sample};
         CUDA_GET_BLOCKSIZE(convert_to_rgb_func, rect_size.x, rect_size.y);
         CUDA_LAUNCH_KERNEL(convert_to_rgb_func, args);
 
@@ -920,8 +922,6 @@ class OptiXDevice : public CUDADevice {
       CUDADevice::denoise(rtile, denoising);
     }
 
-    // Update current sample, so it is displayed correctly
-    rtile.sample = total_samples;
     // Update task progress after the denoiser completed processing
     task.update_progress(&rtile, rtile.w * rtile.h);
 
@@ -1448,6 +1448,11 @@ class OptiXDevice : public CUDADevice {
     // Upload texture information to device if it has changed since last launch
     load_texture_info();
 
+    {  // Synchronize all memory copies before executing task
+      const CUDAContextScope scope(cuContext);
+      check_result_cuda(cuCtxSynchronize());
+    }
+
     if (task.type == DeviceTask::FILM_CONVERT) {
       // Execute in main thread because of OpenGL access
       film_convert(task, task.buffer, task.rgba_byte, task.rgba_half);



More information about the Bf-blender-cvs mailing list