Merge branch 'blender-v4.1-release' into main

This commit is contained in:
Brecht Van Lommel 2024-02-09 15:16:55 +01:00
commit 01f2c32700
5 changed files with 29 additions and 10 deletions

View File

@ -86,8 +86,14 @@ Device *Denoiser::get_denoiser_device() const
}
/* Check whether given device is single (not a MultiDevice) and supports requested denoiser. */
static bool is_single_supported_device(Device *device, DenoiserType type)
static bool is_single_supported_device(const Device *device,
const uint device_type_mask,
const DenoiserType type)
{
if (!(device_type_mask & (1 << device->info.type))) {
return false;
}
if (device->info.type == DEVICE_MULTI) {
/* Assume multi-device is never created with a single sub-device.
* If one requests such configuration it should be checked on the session level. */
@ -109,11 +115,16 @@ static bool is_single_supported_device(Device *device, DenoiserType type)
* multi-device.
*
* If there is no device available which supports given denoiser type nullptr is returned. */
static Device *find_best_device(Device *device, DenoiserType type)
static Device *find_best_device(Device *device,
const uint device_type_mask,
const DenoiserType type)
{
Device *best_device = nullptr;
device->foreach_device([&](Device *sub_device) {
if (!(device_type_mask & (1 << sub_device->info.type))) {
return;
}
if ((sub_device->info.denoisers & type) == 0) {
return;
}
@ -137,7 +148,7 @@ static Device *find_best_device(Device *device, DenoiserType type)
}
static DeviceInfo find_best_denoiser_device_info(const vector<DeviceInfo> &device_infos,
DenoiserType denoiser_type)
const DenoiserType denoiser_type)
{
for (const DeviceInfo &device_info : device_infos) {
if ((device_info.denoisers & denoiser_type) == 0) {
@ -159,7 +170,7 @@ static DeviceInfo find_best_denoiser_device_info(const vector<DeviceInfo> &devic
static unique_ptr<Device> create_denoiser_device(Device *path_trace_device,
const uint device_type_mask,
DenoiserType denoiser_type)
const DenoiserType denoiser_type)
{
const vector<DeviceInfo> device_infos = Device::available_devices(device_type_mask);
if (device_infos.empty()) {
@ -199,14 +210,16 @@ Device *Denoiser::ensure_denoiser_device(Progress *progress)
return denoiser_device_;
}
const uint device_type_mask = get_device_type_mask();
/* Simple case: rendering happens on a single device which also supports denoiser. */
if (is_single_supported_device(path_trace_device_, params_.type)) {
if (is_single_supported_device(path_trace_device_, device_type_mask, params_.type)) {
denoiser_device_ = path_trace_device_;
return denoiser_device_;
}
/* Find best device from the ones which are already used for rendering. */
denoiser_device_ = find_best_device(path_trace_device_, params_.type);
denoiser_device_ = find_best_device(path_trace_device_, device_type_mask, params_.type);
if (denoiser_device_) {
return denoiser_device_;
}
@ -217,7 +230,6 @@ Device *Denoiser::ensure_denoiser_device(Progress *progress)
device_creation_attempted_ = true;
const uint device_type_mask = get_device_type_mask();
local_denoiser_device_ = create_denoiser_device(
path_trace_device_, device_type_mask, params_.type);
denoiser_device_ = local_denoiser_device_.get();

View File

@ -1002,6 +1002,9 @@ void PathTrace::process_full_buffer_from_disk(string_view filename)
if (denoise_params.use) {
progress_set_status(layer_view_name, "Denoising");
/* If GPU should be used is not based on file metadata. */
denoise_params.use_gpu = render_scheduler_.is_denoiser_gpu_used();
/* Re-use the denoiser as much as possible, avoiding possible device re-initialization.
*
* It will not conflict with the regular rendering as:

View File

@ -46,6 +46,11 @@ void RenderScheduler::set_denoiser_params(const DenoiseParams &params)
denoiser_params_ = params;
}
bool RenderScheduler::is_denoiser_gpu_used() const
{
return denoiser_params_.use_gpu;
}
void RenderScheduler::set_limit_samples_per_update(const int limit_samples)
{
limit_samples_per_update_ = limit_samples;

View File

@ -99,8 +99,9 @@ class RenderScheduler {
bool is_background() const;
void set_denoiser_params(const DenoiseParams &params);
void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling);
bool is_denoiser_gpu_used() const;
void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling);
bool is_adaptive_sampling_used() const;
/* Start sample for path tracing.

View File

@ -147,8 +147,6 @@ def main():
test_dir_name = Path(test_dir).name
if test_dir_name in ('motion_blur', 'integrator', ):
report.set_fail_threshold(0.032)
if test_dir_name == "denoise":
report.set_fail_threshold(0.25)
ok = report.run(test_dir, blender, get_arguments, batch=args.batch)