Fix: Cycles assert in device consistency check

A regression since #118841.

It is possible that the selected preference device is not found, in which
case a default-initialized DeviceInfo would have added to the list. This
device is set to CPU, but with differnet other fields (such as description)
compared to the actual CPU device.

Pull Request: https://projects.blender.org/blender/blender/pulls/122701
This commit is contained in:
Sergey Sharybin
2024-06-04 12:49:30 +02:00
committed by Sergey Sharybin
parent 6ce4e94eb9
commit 11d311e300
2 changed files with 9 additions and 5 deletions

View File

@@ -108,8 +108,8 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences,
/* Default to CPU device. */
DeviceInfo cpu_device = Device::available_devices(DEVICE_MASK_CPU).front();
/* Device, which is choosen in the Blender Preferences. */
preferences_device = DeviceInfo();
/* Device, which is choosen in the Blender Preferences. Default to CPU device. */
preferences_device = cpu_device;
/* Test if we are using GPU devices. */
ComputeDevice compute_device = (ComputeDevice)get_enum(
@@ -155,10 +155,10 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences,
preferences_device = Device::get_multi_device(used_devices, threads, background);
}
}
else {
preferences_device = cpu_device;
if (preferences_device != cpu_device) {
adjust_device_info(preferences_device, cpreferences, preview);
}
adjust_device_info(preferences_device, cpreferences, preview);
adjust_device_info(cpu_device, cpreferences, preview);
/* Device, which will be used, according to Settings, Scene preferences and command line

View File

@@ -127,6 +127,10 @@ class DeviceInfo {
return id == info.id && use_hardware_raytracing == info.use_hardware_raytracing &&
kernel_optimization_level == info.kernel_optimization_level;
}
bool operator!=(const DeviceInfo &info) const
{
return !(*this == info);
}
};
/* Device */