diff options
author | Patrick Mours <pmours@nvidia.com> | 2022-01-04 23:39:54 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2022-01-05 17:58:36 +0300 |
commit | 8393ccd07634b3152b18d4d527b1460dab9dbe06 (patch) | |
tree | 816b4dcaa9b8e5163c3934743fe1604f02983e71 /intern/cycles/session/denoising.h | |
parent | 86141a75ebc5d0517edf71f2bc2fe7d0d13d8b5e (diff) |
Cycles: Add OptiX temporal denoising support
Enables the `bpy.ops.cycles.denoise_animation()` operator again and modifies it to support
temporal denoising with OptiX. This requires renders that were done with both the "Vector"
and "Denoising Data" passes.
Differential Revision: https://developer.blender.org/D11442
Diffstat (limited to 'intern/cycles/session/denoising.h')
-rw-r--r-- | intern/cycles/session/denoising.h | 76 |
1 files changed, 22 insertions, 54 deletions
diff --git a/intern/cycles/session/denoising.h b/intern/cycles/session/denoising.h index 097cc570d06..15e691f73fd 100644 --- a/intern/cycles/session/denoising.h +++ b/intern/cycles/session/denoising.h @@ -17,20 +17,17 @@ #ifndef __DENOISING_H__ #define __DENOISING_H__ -#if 0 - /* TODO(sergey): Make it explicit and clear when something is a denoiser, its pipeline or * parameters. Currently it is an annoying mixture of terms used interchangeably. */ -# include "device/device.h" - -# include "render/buffers.h" +#include "device/device.h" +#include "integrator/denoiser.h" -# include "util/util_string.h" -# include "util/util_unique_ptr.h" -# include "util/util_vector.h" +#include "util/string.h" +#include "util/unique_ptr.h" +#include "util/vector.h" -# include <OpenImageIO/imageio.h> +#include <OpenImageIO/imageio.h> OIIO_NAMESPACE_USING @@ -40,7 +37,7 @@ CCL_NAMESPACE_BEGIN class DenoiserPipeline { public: - DenoiserPipeline(DeviceInfo &device_info); + DenoiserPipeline(DeviceInfo &device_info, const DenoiseParams ¶ms); ~DenoiserPipeline(); bool run(); @@ -55,22 +52,13 @@ class DenoiserPipeline { * taking into account all input frames. */ vector<string> output; - /* Sample number override, takes precedence over values from input frames. */ - int samples_override; - /* Tile size for processing on device. */ - int2 tile_size; - - /* Equivalent to the settings in the regular denoiser. */ - DenoiseParams params; - protected: friend class DenoiseTask; Stats stats; Profiler profiler; Device *device; - - int num_frames; + std::unique_ptr<Denoiser> denoiser; }; /* Denoise Image Layer */ @@ -88,13 +76,13 @@ struct DenoiseImageLayer { /* Device input channel will be copied from image channel input_to_image_channel[i]. */ 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; - /* 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; + /* output_to_image_channel of the previous frame, if used. */ + vector<int> previous_output_to_image_channel; + /* Detect whether this layer contains a full set of channels and set up the offsets accordingly. */ bool detect_denoising_channels(); @@ -102,8 +90,7 @@ struct DenoiseImageLayer { /* Map the channels of a secondary frame to the channels that are required for processing, * fill neighbor_input_to_image_channel if all are present or return false if a channel are * missing. */ - bool match_channels(int neighbor, - const std::vector<string> &channelnames, + bool match_channels(const std::vector<string> &channelnames, const std::vector<string> &neighbor_channelnames); }; @@ -125,7 +112,7 @@ class DenoiseImage { /* Image file handles */ ImageSpec in_spec; - vector<unique_ptr<ImageInput>> in_neighbors; + unique_ptr<ImageInput> in_previous; /* Render layers */ vector<DenoiseImageLayer> layers; @@ -137,12 +124,16 @@ class DenoiseImage { bool load(const string &in_filepath, string &error); /* Load neighboring frames. */ - bool load_neighbors(const vector<string> &filepaths, const vector<int> &frames, string &error); + bool load_previous(const string &in_filepath, string &error); /* Load subset of pixels from file buffer into input buffer, as needed for denoising * on the device. Channels are reshuffled following the provided mapping. */ - void read_pixels(const DenoiseImageLayer &layer, float *input_pixels); - bool read_neighbor_pixels(int neighbor, const DenoiseImageLayer &layer, float *input_pixels); + void read_pixels(const DenoiseImageLayer &layer, + const BufferParams ¶ms, + float *input_pixels); + bool read_previous_pixels(const DenoiseImageLayer &layer, + const BufferParams ¶ms, + float *input_pixels); bool save_output(const string &out_filepath, string &error); @@ -159,10 +150,7 @@ class DenoiseImage { class DenoiseTask { public: - DenoiseTask(Device *device, - DenoiserPipeline *denoiser, - int frame, - const vector<int> &neighbor_frames); + DenoiseTask(Device *device, DenoiserPipeline *denoiser, int frame); ~DenoiseTask(); /* Task stages */ @@ -180,37 +168,17 @@ class DenoiseTask { /* Frame number to be denoised */ int frame; - vector<int> neighbor_frames; /* Image file data */ DenoiseImage image; int current_layer; - /* Device input buffer */ - device_vector<float> input_pixels; - - /* Tiles */ - thread_mutex tiles_mutex; - list<RenderTile> tiles; - int num_tiles; - - thread_mutex output_mutex; - map<int, device_vector<float> *> output_pixels; + RenderBuffers buffers; /* Task handling */ bool load_input_pixels(int layer); - void create_task(DeviceTask &task); - - /* Device task callbacks */ - bool acquire_tile(Device *device, Device *tile_device, RenderTile &tile); - void map_neighboring_tiles(RenderTileNeighbors &neighbors, Device *tile_device); - void unmap_neighboring_tiles(RenderTileNeighbors &neighbors); - void release_tile(); - bool get_cancel(); }; CCL_NAMESPACE_END -#endif - #endif /* __DENOISING_H__ */ |