diff options
author | Patrick Mours <pmours@nvidia.com> | 2019-08-26 18:41:44 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-08-26 18:42:52 +0300 |
commit | c32377da9888cc004cb9216383a9f1383fcf5a03 (patch) | |
tree | d1b164133a99e0980ca1a0fa18829cc4c8689148 /intern/cycles/device/device_memory.h | |
parent | f6da680946e2bf982c4831c2135305cb0674215f (diff) |
Cycles: support move semantics for device_memory
Ref D5363
Diffstat (limited to 'intern/cycles/device/device_memory.h')
-rw-r--r-- | intern/cycles/device/device_memory.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h index f50184efba7..5b43ce8b0bc 100644 --- a/intern/cycles/device/device_memory.h +++ b/intern/cycles/device/device_memory.h @@ -229,8 +229,11 @@ class device_memory { device_memory(Device *device, const char *name, MemoryType type); /* No copying allowed. */ - device_memory(const device_memory &); - device_memory &operator=(const device_memory &); + device_memory(const device_memory &) = delete; + device_memory &operator=(const device_memory &) = delete; + + /* But moving is possible. */ + device_memory(device_memory &&); /* Host allocation on the device. All host_pointer memory should be * allocated with these functions, for devices that support using @@ -269,6 +272,11 @@ template<typename T> class device_only_memory : public device_memory { free(); } + device_only_memory(device_only_memory &&other) + : device_memory(static_cast<device_memory &&>(other)) + { + } + void alloc_to_device(size_t num, bool shrink_to_fit = true) { size_t new_size = num; @@ -327,6 +335,10 @@ template<typename T> class device_vector : public device_memory { free(); } + device_vector(device_vector &&other) : device_memory(static_cast<device_memory &&>(other)) + { + } + /* Host memory allocation. */ T *alloc(size_t width, size_t height = 0, size_t depth = 0) { |