[Bf-blender-cvs] [7524525d993] cycles-x: Fix CPU rendering and OptiX denoiser in Cycles X

Sergey Sharybin noreply at git.blender.org
Tue Jun 29 18:13:11 CEST 2021


Commit: 7524525d993fbaea23b9daa4b34b75f75256d430
Author: Sergey Sharybin
Date:   Tue Jun 29 17:54:28 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB7524525d993fbaea23b9daa4b34b75f75256d430

Fix CPU rendering and OptiX denoiser in Cycles X

Make sure copying of temporary render buffers to the device
happens as part of the denoiser queue.

Initially thought this will be fixed by some more global changes
related to multi-GPU support, but:

- It is a simple and clear change.
- It brings multi-device support to a working state, which makes
  it easier to verify changes.
- Multi-device is supported at a higher level, and it could still
  be useful to support current usecases of DeviceDenoiser (where
  input render buffers are allocated on a different device).

Differential Revision: https://developer.blender.org/D11742

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

M	intern/cycles/device/device.h
M	intern/cycles/device/optix/device_impl.cpp
M	intern/cycles/device/optix/device_impl.h
M	intern/cycles/integrator/denoiser_device.cpp

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

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index a39f5b328c2..de3920f1cf3 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -381,6 +381,12 @@ class Device {
     LOG(ERROR) << "Request buffer denoising from a device which does not support it.";
   }
 
+  virtual DeviceQueue *get_denoise_queue()
+  {
+    LOG(ERROR) << "Request denoising queue from a device which does not support it.";
+    return nullptr;
+  }
+
   /* Sub-devices */
 
   /* Run given callback for every individual device which will be handling rendering.
diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp
index e4b78ece648..85b1934399c 100644
--- a/intern/cycles/device/optix/device_impl.cpp
+++ b/intern/cycles/device/optix/device_impl.cpp
@@ -590,6 +590,11 @@ void OptiXDevice::denoise_buffer(const DeviceDenoiseTask &task)
   denoise_pass(context, PASS_SHADOW_CATCHER_MATTE);
 }
 
+DeviceQueue *OptiXDevice::get_denoise_queue()
+{
+  return &denoiser_.queue;
+}
+
 void OptiXDevice::denoise_pass(DenoiseContext &context, PassType pass_type)
 {
   const BufferParams &buffer_params = context.buffer_params;
diff --git a/intern/cycles/device/optix/device_impl.h b/intern/cycles/device/optix/device_impl.h
index caab62c4f05..78a7d382440 100644
--- a/intern/cycles/device/optix/device_impl.h
+++ b/intern/cycles/device/optix/device_impl.h
@@ -145,6 +145,7 @@ class OptiXDevice : public CUDADevice {
   class DenoisePass;
 
   virtual void denoise_buffer(const DeviceDenoiseTask &task) override;
+  virtual DeviceQueue *get_denoise_queue();
 
   void denoise_pass(DenoiseContext &context, PassType pass_type);
 
diff --git a/intern/cycles/integrator/denoiser_device.cpp b/intern/cycles/integrator/denoiser_device.cpp
index 8a0bff8dc21..8b11947a028 100644
--- a/intern/cycles/integrator/denoiser_device.cpp
+++ b/intern/cycles/integrator/denoiser_device.cpp
@@ -19,6 +19,7 @@
 #include "device/device.h"
 #include "device/device_denoise.h"
 #include "device/device_memory.h"
+#include "device/device_queue.h"
 #include "render/buffers.h"
 #include "util/util_logging.h"
 #include "util/util_progress.h"
@@ -186,6 +187,8 @@ void DeviceDenoiser::denoise_buffer_on_device(Device *device,
     task.render_buffers = render_buffers;
   }
   else {
+    DeviceQueue *queue = device->get_denoise_queue();
+
     /* Create buffer which is available by the device used by denoiser. */
 
     /* TODO(sergey): Optimize data transfers. For example, only copy denoising related passes,
@@ -203,7 +206,8 @@ void DeviceDenoiser::denoise_buffer_on_device(Device *device,
     memcpy(local_render_buffers.buffer.data(),
            render_buffers->buffer.data(),
            sizeof(float) * local_render_buffers.buffer.size());
-    local_render_buffers.copy_to_device();
+
+    queue->copy_to_device(local_render_buffers.buffer);
 
     task.render_buffers = &local_render_buffers;
   }



More information about the Bf-blender-cvs mailing list