Fixes for API changes done in Blender 2.80
Seems to work with both Blender 2.79 and 2,80.
This commit is contained in:
@@ -2,6 +2,24 @@
|
||||
|
||||
import bpy
|
||||
|
||||
def getUserPreferences(context):
|
||||
preferences = getattr(context, 'user_preferences', None)
|
||||
if preferences is None:
|
||||
preferences = context.preferences
|
||||
return preferences
|
||||
|
||||
|
||||
def getAllAvailableDevices():
|
||||
import _cycles
|
||||
all_devices = []
|
||||
blender_version = bpy.app.version
|
||||
if bpy.app.version < (2, 80, 0):
|
||||
return _cycles.available_devices()
|
||||
all_devices.extend(_cycles.available_devices('CPU'))
|
||||
all_devices.extend(_cycles.available_devices('CUDA'))
|
||||
all_devices.extend(_cycles.available_devices('OPENCL'))
|
||||
return all_devices
|
||||
|
||||
def setDeviceCPU(context, cpref):
|
||||
cpref.compute_device_type = 'NONE'
|
||||
return True
|
||||
@@ -148,13 +166,13 @@ def logComputeDevices(cpref):
|
||||
def logSystemInfo(cpref):
|
||||
import json
|
||||
info_devices = []
|
||||
for device in cpref.devices:
|
||||
for device in getAllAvailableDevices():
|
||||
info_device = {
|
||||
"name": device.name.replace(" (Display)", ""),
|
||||
"type": device.type,
|
||||
"name": device[0].replace(" (Display)", ""),
|
||||
"type": device[1],
|
||||
}
|
||||
if device.type != 'CPU':
|
||||
info_device["is_display"] = '(Display)' in device.name
|
||||
if device[1] != 'CPU':
|
||||
info_device["is_display"] = '(Display)' in device[0]
|
||||
info_devices.append(info_device)
|
||||
print("Benchmark Devices: {}" . format(json.dumps(info_devices, sort_keys=True)))
|
||||
|
||||
@@ -195,7 +213,7 @@ def main():
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
context = bpy.context
|
||||
cpref = context.user_preferences.addons['cycles'].preferences
|
||||
cpref = getUserPreferences(context).addons['cycles'].preferences
|
||||
|
||||
# Adjust samples so we render real quick.
|
||||
if args.benchmark_warmup:
|
||||
|
Reference in New Issue
Block a user