Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-11-01 00:23:37 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-11-01 10:36:50 +0300
commit28eaa81f1e9a59c41b58834fcef6b5f3581a2581 (patch)
tree4fdbd5e4865fd7d918ade113571725b515bc7541
parent0b060905d98cf4b266e73d9be5471dc0b3e71ecc (diff)
Fix Cycles Python warnings when removed OpenCL device was enabled
-rw-r--r--intern/cycles/blender/addon/properties.py21
-rw-r--r--intern/cycles/blender/addon/version_update.py8
2 files changed, 21 insertions, 8 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 1e98e6d0a7c..c92e0ec65af 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1360,7 +1360,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
elif entry.type == 'CPU':
cpu_devices.append(entry)
# Extend all GPU devices with CPU.
- if compute_device_type != 'CPU':
+ if len(devices) and compute_device_type != 'CPU':
devices.extend(cpu_devices)
return devices
@@ -1378,12 +1378,18 @@ class CyclesPreferences(bpy.types.AddonPreferences):
self.refresh_devices()
return None
+ def get_compute_device_type(self):
+ if self.compute_device_type == '':
+ return 'NONE'
+ return self.compute_device_type
+
def get_num_gpu_devices(self):
import _cycles
- device_list = _cycles.available_devices(self.compute_device_type)
+ 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] != self.compute_device_type:
+ if device[1] != compute_device_type:
continue
for dev in self.devices:
if dev.use and dev.id == device[2]:
@@ -1425,15 +1431,16 @@ class CyclesPreferences(bpy.types.AddonPreferences):
row = layout.row()
row.prop(self, "compute_device_type", expand=True)
- if self.compute_device_type == 'NONE':
+ compute_device_type = self.get_compute_device_type()
+ if compute_device_type == 'NONE':
return
row = layout.row()
- devices = self.get_devices_for_type(self.compute_device_type)
- self._draw_devices(row, self.compute_device_type, devices)
+ devices = self.get_devices_for_type(compute_device_type)
+ self._draw_devices(row, compute_device_type, devices)
import _cycles
has_peer_memory = 0
- for device in _cycles.available_devices(self.compute_device_type):
+ for device in _cycles.available_devices(compute_device_type):
if device[3] and self.find_existing_device_entry(device).use:
has_peer_memory += 1
if has_peer_memory > 1:
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index b3e8e755903..90ed8873c02 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -86,7 +86,7 @@ def do_versions(self):
# Device might not currently be available so this can fail
try:
if system.legacy_compute_device_type == 1:
- prop.compute_device_type = 'OPENCL'
+ prop.compute_device_type = 'NONE' # Was OpenCL
elif system.legacy_compute_device_type == 2:
prop.compute_device_type = 'CUDA'
else:
@@ -97,6 +97,12 @@ def do_versions(self):
# Init device list for UI
prop.get_devices(prop.compute_device_type)
+ if bpy.context.preferences.version <= (3, 0, 40):
+ # Disable OpenCL device
+ prop = bpy.context.preferences.addons[__package__].preferences
+ if prop['compute_device_type'] == 4:
+ prop.compute_device_type = 'NONE'
+
# We don't modify startup file because it assumes to
# have all the default values only.
if not bpy.data.is_saved: