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
|
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):
|
def setDeviceCPU(context, cpref):
|
||||||
cpref.compute_device_type = 'NONE'
|
cpref.compute_device_type = 'NONE'
|
||||||
return True
|
return True
|
||||||
@@ -148,13 +166,13 @@ def logComputeDevices(cpref):
|
|||||||
def logSystemInfo(cpref):
|
def logSystemInfo(cpref):
|
||||||
import json
|
import json
|
||||||
info_devices = []
|
info_devices = []
|
||||||
for device in cpref.devices:
|
for device in getAllAvailableDevices():
|
||||||
info_device = {
|
info_device = {
|
||||||
"name": device.name.replace(" (Display)", ""),
|
"name": device[0].replace(" (Display)", ""),
|
||||||
"type": device.type,
|
"type": device[1],
|
||||||
}
|
}
|
||||||
if device.type != 'CPU':
|
if device[1] != 'CPU':
|
||||||
info_device["is_display"] = '(Display)' in device.name
|
info_device["is_display"] = '(Display)' in device[0]
|
||||||
info_devices.append(info_device)
|
info_devices.append(info_device)
|
||||||
print("Benchmark Devices: {}" . format(json.dumps(info_devices, sort_keys=True)))
|
print("Benchmark Devices: {}" . format(json.dumps(info_devices, sort_keys=True)))
|
||||||
|
|
||||||
@@ -195,7 +213,7 @@ def main():
|
|||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
context = bpy.context
|
context = bpy.context
|
||||||
cpref = context.user_preferences.addons['cycles'].preferences
|
cpref = getUserPreferences(context).addons['cycles'].preferences
|
||||||
|
|
||||||
# Adjust samples so we render real quick.
|
# Adjust samples so we render real quick.
|
||||||
if args.benchmark_warmup:
|
if args.benchmark_warmup:
|
||||||
|
Reference in New Issue
Block a user