diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-13 16:34:26 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-13 16:34:26 +0300 |
commit | 74a3d9b410e671b81b6b41e16dd9b158882521d3 (patch) | |
tree | dd34df2dee0f6b47739434a363504bf20ba31d34 | |
parent | 1bbe770030a93c38e4fd95f4e65009385c33ab34 (diff) | |
parent | 3866161da855d2b35ac48ef55958bcb567d4a740 (diff) |
Merge branch 'blender2.7'
-rw-r--r-- | intern/cycles/device/device.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/render/denoising.cpp | 38 | ||||
-rw-r--r-- | intern/cycles/render/denoising.h | 7 | ||||
-rw-r--r-- | intern/cycles/util/util_guarded_allocator.h | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 1 |
5 files changed, 19 insertions, 47 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 5b53dc9d937..40d17b7f3d6 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -601,10 +601,10 @@ void Device::tag_update() void Device::free_memory() { devices_initialized_mask = 0; - cuda_devices.clear(); - opencl_devices.clear(); - cpu_devices.clear(); - network_devices.clear(); + cuda_devices.free_memory(); + opencl_devices.free_memory(); + cpu_devices.free_memory(); + network_devices.free_memory(); } CCL_NAMESPACE_END diff --git a/intern/cycles/render/denoising.cpp b/intern/cycles/render/denoising.cpp index 0016a067cf9..bbc9f61522c 100644 --- a/intern/cycles/render/denoising.cpp +++ b/intern/cycles/render/denoising.cpp @@ -123,7 +123,7 @@ static void fill_mapping(vector<ChannelMapping> &map, int pos, string name, stri } static const int INPUT_NUM_CHANNELS = 15; -static vector<ChannelMapping> init_input_channels() +static vector<ChannelMapping> input_channels() { vector<ChannelMapping> map; fill_mapping(map, 0, "Denoising Depth", "Z"); @@ -137,16 +137,13 @@ static vector<ChannelMapping> init_input_channels() } static const int OUTPUT_NUM_CHANNELS = 3; -static vector<ChannelMapping> init_output_channels() +static vector<ChannelMapping> output_channels() { vector<ChannelMapping> map; fill_mapping(map, 0, "Combined", "RGB"); return map; } -static const vector<ChannelMapping> input_channels = init_input_channels(); -static const vector<ChannelMapping> output_channels = init_output_channels(); - /* Renderlayer Handling */ bool DenoiseImageLayer::detect_denoising_channels() @@ -155,7 +152,7 @@ bool DenoiseImageLayer::detect_denoising_channels() input_to_image_channel.clear(); input_to_image_channel.resize(INPUT_NUM_CHANNELS, -1); - foreach(const ChannelMapping& mapping, input_channels) { + foreach(const ChannelMapping& mapping, input_channels()) { vector<string>::iterator i = find(channels.begin(), channels.end(), mapping.name); if(i == channels.end()) { return false; @@ -170,7 +167,7 @@ bool DenoiseImageLayer::detect_denoising_channels() output_to_image_channel.clear(); output_to_image_channel.resize(OUTPUT_NUM_CHANNELS, -1); - foreach(const ChannelMapping& mapping, output_channels) { + foreach(const ChannelMapping& mapping, output_channels()) { vector<string>::iterator i = find(channels.begin(), channels.end(), mapping.name); if(i == channels.end()) { return false; @@ -554,18 +551,8 @@ DenoiseImage::~DenoiseImage() void DenoiseImage::close_input() { - foreach(ImageInput *i, in_neighbors) { - i->close(); - ImageInput::destroy(i); - } - in_neighbors.clear(); - - if(in) { - in->close(); - ImageInput::destroy(in); - in = NULL; - } + in.reset(); } void DenoiseImage::free() @@ -675,7 +662,7 @@ bool DenoiseImage::load(const string& in_filepath, string& error) return false; } - in = ImageInput::open(in_filepath); + in.reset(ImageInput::open(in_filepath)); if(!in) { error = "Couldn't open file: " + in_filepath; return false; @@ -724,7 +711,7 @@ bool DenoiseImage::load_neighbors(const vector<string>& filepaths, const vector< return false; } - ImageInput *in_neighbor = ImageInput::open(filepath); + unique_ptr<ImageInput> in_neighbor(ImageInput::open(filepath)); if(!in_neighbor) { error = "Couldn't open neighbor frame: " + filepath; return false; @@ -733,8 +720,6 @@ bool DenoiseImage::load_neighbors(const vector<string>& filepaths, const vector< const ImageSpec &neighbor_spec = in_neighbor->spec(); if(neighbor_spec.width != width || neighbor_spec.height != height) { error = "Neighbor frame has different dimensions: " + filepath; - in_neighbor->close(); - ImageInput::destroy(in_neighbor); return false; } @@ -744,13 +729,11 @@ bool DenoiseImage::load_neighbors(const vector<string>& filepaths, const vector< neighbor_spec.channelnames)) { error = "Neighbor frame misses denoising data passes: " + filepath; - in_neighbor->close(); - ImageInput::destroy(in_neighbor); return false; } } - in_neighbors.push_back(in_neighbor); + in_neighbors.push_back(std::move(in_neighbor)); } return true; @@ -776,7 +759,7 @@ bool DenoiseImage::save_output(const string& out_filepath, string& error) /* Write to temporary file path, so we denoise images in place and don't * risk destroying files when something goes wrong in file saving. */ string tmp_filepath = OIIO::Filesystem::temp_directory_path() + "/" + OIIO::Filesystem::unique_path() + ".exr"; - ImageOutput *out = ImageOutput::create(tmp_filepath); + unique_ptr<ImageOutput> out(ImageOutput::create(tmp_filepath)); if(!out) { error = "Failed to open temporary file " + tmp_filepath + " for writing"; @@ -786,7 +769,6 @@ bool DenoiseImage::save_output(const string& out_filepath, string& error) /* Open temporary file and write image buffers. */ if(!out->open(tmp_filepath, out_spec)) { error = "Failed to open file " + tmp_filepath + " for writing: " + out->geterror(); - ImageOutput::destroy(out); return false; } @@ -801,7 +783,7 @@ bool DenoiseImage::save_output(const string& out_filepath, string& error) ok = false; } - ImageOutput::destroy(out); + out.reset(); /* Copy temporary file to outputput filepath. */ if(ok && !OIIO::Filesystem::rename(tmp_filepath, out_filepath)) { diff --git a/intern/cycles/render/denoising.h b/intern/cycles/render/denoising.h index 15e690a2f45..85a1c7d0391 100644 --- a/intern/cycles/render/denoising.h +++ b/intern/cycles/render/denoising.h @@ -24,6 +24,7 @@ #include "util/util_string.h" #include "util/util_vector.h" +#include "util/util_unique_ptr.h" #include <OpenImageIO/imageio.h> @@ -84,7 +85,7 @@ struct DenoiseImageLayer { vector<int> input_to_image_channel; /* input_to_image_channel of the secondary frames, if any are used. */ - vector<vector<int> > neighbor_input_to_image_channel; + vector<vector<int>> neighbor_input_to_image_channel; /* Write i-th channel of the processing output to output_to_image_channel[i]-th channel of the file. */ vector<int> output_to_image_channel; @@ -116,8 +117,8 @@ public: array<float> pixels; /* Image file handles */ - ImageInput *in; - vector<ImageInput*> in_neighbors; + unique_ptr<ImageInput> in; + vector<unique_ptr<ImageInput>> in_neighbors; /* Render layers */ vector<DenoiseImageLayer> layers; diff --git a/intern/cycles/util/util_guarded_allocator.h b/intern/cycles/util/util_guarded_allocator.h index 2c6f1790fd0..99edf77e2c7 100644 --- a/intern/cycles/util/util_guarded_allocator.h +++ b/intern/cycles/util/util_guarded_allocator.h @@ -97,18 +97,6 @@ public: return *this; } - void construct(T *p, const T& val) - { - if(p != NULL) { - new ((T *)p) T(val); - } - } - - void destroy(T *p) - { - p->~T(); - } - size_t max_size() const { return size_t(-1); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 0adaf598562..7230b65738b 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3592,6 +3592,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) static const char *cpp_classes = "" "\n" +"#include <stdlib.h> /* for malloc */\n" "#include <string>\n" "#include <string.h> /* for memcpy */\n" "\n" |