diff options
Diffstat (limited to 'intern/cycles/device/device_multi.cpp')
-rw-r--r-- | intern/cycles/device/device_multi.cpp | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 91507e6be0c..587840e551f 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -285,26 +285,27 @@ public: mem.copy_from_device(0, mem.data_size, 1); } - Device *original_device = mem.device; - device_ptr original_ptr = mem.device_pointer; - size_t original_size = mem.device_size; - - mem.device = sub_device; - mem.device_pointer = 0; - mem.device_size = 0; + mem.swap_device(sub_device, 0, 0); mem.copy_to_device(); tiles[i].buffer = mem.device_pointer; + tiles[i].device_size = mem.device_size; - mem.device = original_device; - mem.device_pointer = original_ptr; - mem.device_size = original_size; + mem.restore_device(); } } } void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles) { + /* Copy denoised result back to the host. */ + device_vector<float> &mem = tiles[9].buffers->buffer; + mem.swap_device(sub_device, tiles[9].device_size, tiles[9].buffer); + mem.copy_from_device(0, mem.data_size, 1); + mem.restore_device(); + /* Copy denoised result to the original device. */ + mem.copy_to_device(); + for(int i = 0; i < 9; i++) { if(!tiles[i].buffers) { continue; @@ -312,28 +313,9 @@ public: device_vector<float> &mem = tiles[i].buffers->buffer; if(mem.device != sub_device) { - Device *original_device = mem.device; - device_ptr original_ptr = mem.device_pointer; - size_t original_size = mem.device_size; - - mem.device = sub_device; - mem.device_pointer = tiles[i].buffer; - - /* Copy denoised tile to the host. */ - if(i == 4) { - mem.copy_from_device(0, mem.data_size, 1); - } - + mem.swap_device(sub_device, tiles[i].device_size, tiles[i].buffer); sub_device->mem_free(mem); - - mem.device = original_device; - mem.device_pointer = original_ptr; - mem.device_size = original_size; - - /* Copy denoised tile to the original device. */ - if(i == 4) { - mem.copy_to_device(); - } + mem.restore_device(); } } } @@ -397,4 +379,3 @@ Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background) } CCL_NAMESPACE_END - |