Commit: 1136b40fada99b3b3ac1e936fad80f4a48a9aa19 Author: Sergey Sharybin Date: Fri Jul 9 15:33:15 2021 +0200 Branches: cycles-x https://developer.blender.org/rB1136b40fada99b3b3ac1e936fad80f4a48a9aa19
Cycles X: Improve navigation when OIDN is used in viewport Inform OIDN to stop denoising whenever cancel is requested via the PathTrace. The improvement is especially noticeable when denoising shadow catcher pass which involves denoising 3 passes. Did not measure any eprformance penalty with this change when no cancel is requested during the denoising process. Differential Revision: https://developer.blender.org/D11867 =================================================================== M intern/cycles/integrator/denoiser.h M intern/cycles/integrator/denoiser_oidn.cpp M intern/cycles/integrator/path_trace.cpp =================================================================== diff --git a/intern/cycles/integrator/denoiser.h b/intern/cycles/integrator/denoiser.h index 5870da694f9..0995c00bebb 100644 --- a/intern/cycles/integrator/denoiser.h +++ b/intern/cycles/integrator/denoiser.h @@ -21,6 +21,7 @@ #include "device/device.h" #include "device/device_denoise.h" +#include "util/util_function.h" #include "util/util_unique_ptr.h" CCL_NAMESPACE_BEGIN @@ -95,6 +96,16 @@ class Denoiser { * access to this device happen. */ Device *get_denoiser_device() const; + function<bool(void)> is_cancelled_cb; + + bool is_cancelled() const + { + if (!is_cancelled_cb) { + return false; + } + return is_cancelled_cb(); + } + protected: Denoiser(Device *path_trace_device, const DenoiseParams ¶ms); diff --git a/intern/cycles/integrator/denoiser_oidn.cpp b/intern/cycles/integrator/denoiser_oidn.cpp index 45a326aef91..29e1e85b369 100644 --- a/intern/cycles/integrator/denoiser_oidn.cpp +++ b/intern/cycles/integrator/denoiser_oidn.cpp @@ -65,6 +65,14 @@ OIDNDenoiser::~OIDNDenoiser() * per the OIDN denoiser header. */ } +#ifdef WITH_OPENIMAGEDENOISE +static bool oidn_progress_monitor_function(void *user_ptr, double /*n*/) +{ + OIDNDenoiser *oidn_denoiser = reinterpret_cast<OIDNDenoiser *>(user_ptr); + return !oidn_denoiser->is_cancelled(); +} +#endif + bool OIDNDenoiser::load_kernels(Progress *progress) { if (!Denoiser::load_kernels(progress)) { @@ -92,6 +100,8 @@ bool OIDNDenoiser::load_kernels(Progress *progress) state_->oidn_filter = state_->oidn_device.newFilter("RT"); state_->oidn_filter.set("hdr", true); state_->oidn_filter.set("srgb", false); + + state_->oidn_filter.setProgressMonitorFunction(oidn_progress_monitor_function, this); } state_->use_pass_albedo = params_.use_pass_albedo; @@ -555,9 +565,15 @@ void OIDNDenoiser::denoise_buffer(const BufferParams &buffer_params, if (context.need_denoising()) { context.read_guiding_passes(); - context.denoise_pass(PASS_COMBINED); - context.denoise_pass(PASS_SHADOW_CATCHER); - context.denoise_pass(PASS_SHADOW_CATCHER_MATTE); + const std::array<PassType, 3> passes = { + {PASS_COMBINED, PASS_SHADOW_CATCHER, PASS_SHADOW_CATCHER_MATTE}}; + + for (const PassType pass_type : passes) { + context.denoise_pass(pass_type); + if (is_cancelled()) { + return; + } + } } #endif diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp index 87e5a6fb53d..1310922ac25 100644 --- a/intern/cycles/integrator/path_trace.cpp +++ b/intern/cycles/integrator/path_trace.cpp @@ -393,6 +393,7 @@ void PathTrace::set_denoiser_params(const DenoiseParams ¶ms) } denoiser_ = Denoiser::create(device_, params); + denoiser_->is_cancelled_cb = [this]() { return is_cancel_requested(); }; } void PathTrace::set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling) _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
