[Bf-blender-cvs] [12d82a30771] cycles-x: Cycles: Extend information provided in the full report

Sergey Sharybin noreply at git.blender.org
Wed Apr 28 12:32:38 CEST 2021


Commit: 12d82a30771ab9de06cffc6c9b493fdc718b6a57
Author: Sergey Sharybin
Date:   Wed Apr 28 10:36:47 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB12d82a30771ab9de06cffc6c9b493fdc718b6a57

Cycles: Extend information provided in the full report

Include actual devices used for path tracing and denoising.

useful for in the following cases:

- Verify that the benchmark was made on the device it was intended to
  be done.

- Easily see which exactly device was used for OptiX denoiser.

- Share and compare different reports, by making it explicit in the
  report itself what conditions the benchmark was run in.

The report is printed at the end of rendering when Blender is run with
the `--debug-cycles` command line argument (verbosity level 2).

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

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

M	intern/cycles/integrator/denoiser.h
M	intern/cycles/integrator/denoiser_device.cpp
M	intern/cycles/integrator/denoiser_device.h
M	intern/cycles/integrator/denoiser_oidn.cpp
M	intern/cycles/integrator/denoiser_oidn.h
M	intern/cycles/integrator/path_trace.cpp
M	intern/cycles/integrator/path_trace.h
M	intern/cycles/integrator/path_trace_work.h
M	intern/cycles/render/session.cpp

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

diff --git a/intern/cycles/integrator/denoiser.h b/intern/cycles/integrator/denoiser.h
index 8b7bd7cb1ce..07ede300434 100644
--- a/intern/cycles/integrator/denoiser.h
+++ b/intern/cycles/integrator/denoiser.h
@@ -19,6 +19,7 @@
 /* TODO(sergey): The integrator folder might not be the best. Is easy to move files around if the
  * better place is figured out. */
 
+#include "device/device.h"
 #include "device/device_denoise.h"
 #include "util/util_unique_ptr.h"
 
@@ -73,6 +74,20 @@ class Denoiser {
                               RenderBuffers *render_buffers,
                               const int num_samples) = 0;
 
+  /* Get access to the device information which is used to perform actual denoising.
+   * Note that this device:
+   *
+   * - Can be different from the device used during denoiser creation. This happens, for example,
+   *   when using OptiX denoiser and rendering on CPU.
+   *
+   * - The denoising device is lazily initialized, so if no denoising was perfoemed yet it is
+   *   possible that device info of type DEVICE_NONE will be returned.
+   *
+   * - No threading safety is ensured in this call. This means, that it is up to caller to ensure
+   *   that there is no threadingconflict between denoising task lazily initializing the device and
+   *   access to this device happen. */
+  virtual DeviceInfo get_denoiser_device_info() const = 0;
+
  protected:
   Denoiser(Device *device, const DenoiseParams &params);
 
diff --git a/intern/cycles/integrator/denoiser_device.cpp b/intern/cycles/integrator/denoiser_device.cpp
index 38a0b04a01f..a40b68f99ee 100644
--- a/intern/cycles/integrator/denoiser_device.cpp
+++ b/intern/cycles/integrator/denoiser_device.cpp
@@ -229,4 +229,15 @@ void DeviceDenoiser::denoise_buffer_on_device(Device *device,
   }
 }
 
+DeviceInfo DeviceDenoiser::get_denoiser_device_info() const
+{
+  if (!denoiser_device_) {
+    DeviceInfo device_info;
+    device_info.type = DEVICE_NONE;
+    return device_info;
+  }
+
+  return denoiser_device_->info;
+}
+
 CCL_NAMESPACE_END
diff --git a/intern/cycles/integrator/denoiser_device.h b/intern/cycles/integrator/denoiser_device.h
index 0f6305aad91..72ef0418d62 100644
--- a/intern/cycles/integrator/denoiser_device.h
+++ b/intern/cycles/integrator/denoiser_device.h
@@ -37,6 +37,8 @@ class DeviceDenoiser : public Denoiser {
                               RenderBuffers *render_buffers,
                               const int num_samples) override;
 
+  virtual DeviceInfo get_denoiser_device_info() const override;
+
  protected:
   /* Get device on which denoising is to happen.
    * Will either use one of the devices used for rendering, or create a dedicated device if needed.
diff --git a/intern/cycles/integrator/denoiser_oidn.cpp b/intern/cycles/integrator/denoiser_oidn.cpp
index 32d54d641e2..5097e703dc2 100644
--- a/intern/cycles/integrator/denoiser_oidn.cpp
+++ b/intern/cycles/integrator/denoiser_oidn.cpp
@@ -234,6 +234,31 @@ void OIDNDenoiser::denoise_buffer(const BufferParams &buffer_params,
   render_buffers->buffer.copy_to_device();
 }
 
+DeviceInfo OIDNDenoiser::get_denoiser_device_info() const
+{
+  /* OpenImageDenoiser runs on CPU. Access the CPU device information with some safety fallbacks
+   * for possible variations of Cycles integration. */
+
+  vector<DeviceInfo> cpu_devices = Device::available_devices(DEVICE_MASK_CPU);
+
+  if (cpu_devices.empty()) {
+    LOG(ERROR) << "No CPU devices reported.";
+
+    DeviceInfo dummy_info;
+    dummy_info.type = DEVICE_NONE;
+    return dummy_info;
+  }
+
+  if (cpu_devices.size() > 1) {
+    DeviceInfo device_info;
+    device_info.type = DEVICE_MULTI;
+    device_info.multi_devices = cpu_devices;
+    return device_info;
+  }
+
+  return cpu_devices[0];
+}
+
 void OIDNDenoiser::initialize()
 {
 #ifdef WITH_OPENIMAGEDENOISE
diff --git a/intern/cycles/integrator/denoiser_oidn.h b/intern/cycles/integrator/denoiser_oidn.h
index 0cceb4ce2a1..abf51e17441 100644
--- a/intern/cycles/integrator/denoiser_oidn.h
+++ b/intern/cycles/integrator/denoiser_oidn.h
@@ -38,6 +38,8 @@ class OIDNDenoiser : public Denoiser {
                               RenderBuffers *render_buffers,
                               const int num_samples) override;
 
+  virtual DeviceInfo get_denoiser_device_info() const override;
+
  protected:
   /* Make sure all lazily-initializable resources are initialized and are ready for use by the
    * denoising process. */
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index ea001b403af..cdeb3ec318c 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -422,4 +422,110 @@ bool PathTrace::get_render_tile_pixels(PassAccessor &pass_accessor, float *pixel
   return pass_accessor.get_render_tile_pixels(full_render_buffers_.get(), pixels);
 }
 
+/* --------------------------------------------------------------------
+ * Report generation.
+ */
+
+/* Construct description of the device which will appear in the full report. */
+/* TODO(sergey): Consider making it more reusable utility. */
+static string full_device_info_description(const DeviceInfo &device_info)
+{
+  string full_description = device_info.description;
+
+  if (device_info.display_device) {
+    full_description += " (display)";
+  }
+
+  if (device_info.type == DEVICE_CPU) {
+    full_description += " (" + to_string(device_info.cpu_threads) + " threads)";
+  }
+
+  full_description += " [" + device_info.id + "]";
+
+  return full_description;
+}
+
+/* Construct string which will contain information about devices, possibly multiple of the devices.
+ *
+ * In the simple case the result looks like:
+ *
+ *   Message: Full Device Description
+ *
+ * If there are multiple devices then the result looks like:
+ *
+ *   Message: Full First Device Description
+ *            Full Second Device Description
+ *
+ * Note that the newlines are placed in a way so that the result can be easily concatenated to the
+ * full report. */
+static string device_info_list_report(const string &message, const DeviceInfo &device_info)
+{
+  string result = "\n" + message + ": ";
+  const string pad(message.length() + 2, ' ');
+
+  if (device_info.multi_devices.empty()) {
+    result += full_device_info_description(device_info) + "\n";
+    return result;
+  }
+
+  bool is_first = true;
+  for (const DeviceInfo &sub_device_info : device_info.multi_devices) {
+    if (!is_first) {
+      result += pad;
+    }
+
+    result += full_device_info_description(sub_device_info) + "\n";
+
+    is_first = false;
+  }
+
+  return result;
+}
+
+static string path_trace_devices_report(const vector<unique_ptr<PathTraceWork>> &path_trace_works)
+{
+  DeviceInfo device_info;
+  device_info.type = DEVICE_MULTI;
+
+  for (auto &&path_trace_work : path_trace_works) {
+    device_info.multi_devices.push_back(path_trace_work->get_device()->info);
+  }
+
+  return device_info_list_report("Path tracing on", device_info);
+}
+
+static string denoiser_device_report(const Denoiser *denoiser)
+{
+  if (!denoiser) {
+    return "";
+  }
+
+  if (!denoiser->get_params().use) {
+    return "";
+  }
+
+  const DeviceInfo device_info = denoiser->get_denoiser_device_info();
+  if (device_info.type == DEVICE_NONE) {
+    return "";
+  }
+
+  return device_info_list_report("Denoising on", device_info);
+}
+
+string PathTrace::full_report() const
+{
+  string result = "\nFull path tracing report\n";
+
+  result += path_trace_devices_report(path_trace_works_);
+  result += denoiser_device_report(denoiser_.get());
+
+  /* Report from the render scheduler, which includes:
+   * - Render mode (interactive, offline, headless)
+   * - Adaptive sampling and denoiser parameters
+   * - Breakdown of timing. */
+  result += render_scheduler_.full_report();
+
+  return result;
+}
+
 CCL_NAMESPACE_END
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index 2db57c442a2..f1ef4fc6396 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -106,6 +106,10 @@ class PathTrace {
    * Returns false if any of the accessor's `get_render_tile_pixels()` returned false. */
   bool get_render_tile_pixels(PassAccessor &pass_accessor, float *pixels);
 
+  /* Generate full multi-line report of the rendering process, including rendering parameters,
+   * times, and so on. */
+  string full_report() const;
+
   /* Callback which communicates an updates state of the render buffer.
    * Is called during path tracing to communicate work-in-progress state of the final buffer.
    *
diff --git a/intern/cycles/integrator/path_trace_work.h b/intern/cycles/integrator/path_trace_work.h
index d7efa0b8c86..c34698e2d8d 100644
--- a/intern/cycles/integrator/path_trace_work.h
+++ b/intern/cycles/integrator/path_trace_work.h
@@ -76,6 +76,12 @@ class PathTraceWork {
     return *cancel_requested_flag_;
   }
 
+  /* Access to the device which is used to path trace this work on. */
+  Device *get_device() const
+  {
+    return device_;
+  }
+
  protected:
   PathTraceWork(Device *device,
                 DeviceScene *device_scene,
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index cab565b05a5..5f0ea4a8e9c 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -162,7 +162,7 @@ void Session::run_main_render_loop()
         double total_time, render_time;
         progress.get_time(total_time, render_time);
         VLOG(2) << "Rendering in main loop is done in " << render_time << " seconds.";
-        VLOG(2) << "Full render scheduler report:" << render_scheduler_.full_report();
+        VLOG(2) << path_trace_->full_report();
       }
 
       if (params.background) {



More information about the Bf-blender-cvs mailing list