[Bf-blender-cvs] [f1fe42d912f] master: Cycles: Do not allocate tile buffers on all devices when peer memory is active and denoising is not

Patrick Mours noreply at git.blender.org
Tue Mar 30 14:05:26 CEST 2021


Commit: f1fe42d912f088259bbc82d597121978204e991d
Author: Patrick Mours
Date:   Tue Mar 30 12:59:03 2021 +0200
Branches: master
https://developer.blender.org/rBf1fe42d912f088259bbc82d597121978204e991d

Cycles: Do not allocate tile buffers on all devices when peer memory is active and denoising is not

Separate tile buffers on all devices only need to exist when denoising is active (so any overlap
being rendered simultaneously does not write to the same memory region).
When denoising is not active they can be distributed like all other memory when peer
memory support is available.

Reviewed By: brecht

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

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

M	intern/cycles/device/device_multi.cpp

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

diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index b272e59f99d..35faadcbec5 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -46,10 +46,13 @@ class MultiDevice : public Device {
   list<SubDevice> devices, denoising_devices;
   device_ptr unique_key;
   vector<vector<SubDevice *>> peer_islands;
+  bool use_denoising;
   bool matching_rendering_and_denoising_devices;
 
   MultiDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background_)
-      : Device(info, stats, profiler, background_), unique_key(1)
+      : Device(info, stats, profiler, background_),
+        unique_key(1),
+        use_denoising(!info.denoising_devices.empty())
   {
     foreach (DeviceInfo &subinfo, info.multi_devices) {
       /* Always add CPU devices at the back since GPU devices can change
@@ -194,6 +197,7 @@ class MultiDevice : public Device {
       if (!sub.device->load_kernels(requested_features))
         return false;
 
+    use_denoising = requested_features.use_denoising;
     if (requested_features.use_denoising) {
       /* Only need denoising feature, everything else is unused. */
       DeviceRequestedFeatures denoising_features;
@@ -400,7 +404,7 @@ class MultiDevice : public Device {
     size_t existing_size = mem.device_size;
 
     /* The tile buffers are allocated on each device (see below), so copy to all of them */
-    if (strcmp(mem.name, "RenderBuffers") == 0) {
+    if (strcmp(mem.name, "RenderBuffers") == 0 && use_denoising) {
       foreach (SubDevice &sub, devices) {
         mem.device = sub.device;
         mem.device_pointer = (existing_key) ? sub.ptr_map[existing_key] : 0;
@@ -466,7 +470,7 @@ class MultiDevice : public Device {
     /* This is a hack to only allocate the tile buffers on denoising devices
      * Similarly the tile buffers also need to be allocated separately on all devices so any
      * overlap rendered for denoising does not interfere with each other */
-    if (strcmp(mem.name, "RenderBuffers") == 0) {
+    if (strcmp(mem.name, "RenderBuffers") == 0 && use_denoising) {
       vector<device_ptr> device_pointers;
       device_pointers.reserve(devices.size());
 
@@ -518,7 +522,7 @@ class MultiDevice : public Device {
     size_t existing_size = mem.device_size;
 
     /* Free memory that was allocated for all devices (see above) on each device */
-    if (strcmp(mem.name, "RenderBuffers") == 0 || mem.type == MEM_PIXELS) {
+    if (mem.type == MEM_PIXELS || (strcmp(mem.name, "RenderBuffers") == 0 && use_denoising)) {
       foreach (SubDevice &sub, devices) {
         mem.device = sub.device;
         mem.device_pointer = sub.ptr_map[key];



More information about the Bf-blender-cvs mailing list