Cycles: Update device entries more often

This resolves two issues:
1. On macOS the GPU Compute device would be disabled by default unless
the user opens user preferences. This is unexpected behaviour ever
since 09ba1486f8
2. Fixes incorrect automatic denoiser display settings and errors in
terminal related to the denoising UI on macOS if the user hasn't opened
user preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/123911
This commit is contained in:
Alaska
2024-07-02 16:02:53 +02:00
committed by Sergey Sharybin
parent 4961b93136
commit f3fb3a9ecd

View File

@@ -1648,14 +1648,18 @@ class CyclesPreferences(bpy.types.AddonPreferences):
def get_num_gpu_devices(self):
import _cycles
compute_device_type = self.get_compute_device_type()
device_list = _cycles.available_devices(compute_device_type)
num = 0
for device in device_list:
if device[1] != compute_device_type:
continue
for dev in self.devices:
if dev.use and dev.id == device[2]:
num += 1
if compute_device_type != 'NONE':
device_list = _cycles.available_devices(compute_device_type)
# Device list might be out of sync if the user hasn't opened preference yet
self.update_device_entries(device_list)
for device in device_list:
if device[1] != compute_device_type:
continue
for dev in self.devices:
if dev.use and dev.id == device[2]:
num += 1
return num
def has_multi_device(self):
@@ -1680,7 +1684,10 @@ class CyclesPreferences(bpy.types.AddonPreferences):
# We need non-CPU devices, used for rendering and supporting OIDN GPU denoising
if compute_device_type != 'NONE':
for device in _cycles.available_devices(compute_device_type):
device_list = _cycles.available_devices(compute_device_type)
# Device list might be out of sync if the user hasn't opened preference yet
self.update_device_entries(device_list)
for device in device_list:
device_type = device[1]
if device_type == 'CPU':
continue