Fix T78238: issue loading existing .blend files with Optix viewport denoiser
Also add additional validation to ensure the denoiser is supported before trying to use it.
This commit is contained in:
parent
2b9ac1de49
commit
79c2581bfa
Notes:
blender-bot
2023-02-13 23:39:48 +01:00
Referenced by issue #78238, It is possible for a file to have viewport denoising enabled with no engine selected, which rapidly consumes all memory
|
@ -61,8 +61,10 @@ Session::Session(const SessionParams ¶ms_)
|
|||
|
||||
TaskScheduler::init(params.threads);
|
||||
|
||||
/* Create CPU/GPU devices. */
|
||||
device = Device::create(params.device, stats, profiler, params.background);
|
||||
|
||||
/* Create buffers for interactive rendering. */
|
||||
if (params.background && !params.write_render_cb) {
|
||||
buffers = NULL;
|
||||
display = NULL;
|
||||
|
@ -72,6 +74,9 @@ Session::Session(const SessionParams ¶ms_)
|
|||
display = new DisplayBuffer(device, params.display_buffer_linear);
|
||||
}
|
||||
|
||||
/* Validate denoising parameters. */
|
||||
set_denoising(params.denoising);
|
||||
|
||||
session_thread = NULL;
|
||||
scene = NULL;
|
||||
|
||||
|
@ -944,17 +949,21 @@ void Session::set_pause(bool pause_)
|
|||
|
||||
void Session::set_denoising(const DenoiseParams &denoising)
|
||||
{
|
||||
const bool need_denoise = denoising.need_denoising_task();
|
||||
|
||||
if (need_denoise && !(params.device.denoisers & denoising.type)) {
|
||||
progress.set_error("Denoiser type not supported by compute device");
|
||||
return;
|
||||
}
|
||||
bool need_denoise = denoising.need_denoising_task();
|
||||
|
||||
/* Lock buffers so no denoising operation is triggered while the settings are changed here. */
|
||||
thread_scoped_lock buffers_lock(buffers_mutex);
|
||||
params.denoising = denoising;
|
||||
|
||||
if (!(params.device.denoisers & denoising.type)) {
|
||||
if (need_denoise) {
|
||||
progress.set_error("Denoiser type not supported by compute device");
|
||||
}
|
||||
|
||||
params.denoising.use = false;
|
||||
need_denoise = false;
|
||||
}
|
||||
|
||||
// TODO(pmours): Query the required overlap value for denoising from the device?
|
||||
tile_manager.slice_overlap = need_denoise && !params.background ? 64 : 0;
|
||||
|
||||
|
|
|
@ -1568,6 +1568,7 @@ void do_versions_after_linking_cycles(Main *bmain)
|
|||
}
|
||||
|
||||
if (cscene) {
|
||||
const int DENOISER_AUTO = 0;
|
||||
const int DENOISER_NLM = 1;
|
||||
const int DENOISER_OPTIX = 2;
|
||||
|
||||
|
@ -1578,7 +1579,7 @@ void do_versions_after_linking_cycles(Main *bmain)
|
|||
/* Migrate Optix denoiser to new settings. */
|
||||
if (cycles_property_int(cscene, "preview_denoising", 0)) {
|
||||
cycles_property_boolean_set(cscene, "use_preview_denoising", true);
|
||||
cycles_property_boolean_set(cscene, "preview_denoiser", DENOISER_OPTIX);
|
||||
cycles_property_int_set(cscene, "preview_denoiser", DENOISER_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue