Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/addon/properties.py
| Show All 24 Lines | from bpy.props import (BoolProperty, | ||||
| StringProperty) | StringProperty) | ||||
| # enums | # enums | ||||
| import _cycles | import _cycles | ||||
| enum_devices = ( | enum_devices = ( | ||||
| ('CPU', "CPU", "Use CPU for rendering"), | ('CPU', "CPU", "Use CPU for rendering"), | ||||
| ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in user preferences"), | ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"), | ||||
| ) | ) | ||||
| if _cycles.with_network: | if _cycles.with_network: | ||||
| enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),) | enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),) | ||||
| enum_feature_set = ( | enum_feature_set = ( | ||||
| ('SUPPORTED', "Supported", "Only use finished and supported features"), | ('SUPPORTED', "Supported", "Only use finished and supported features"), | ||||
| ('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1), | ('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1), | ||||
| ▲ Show 20 Lines • Show All 1,141 Lines • ▼ Show 20 Lines | compute_device_type = EnumProperty( | ||||
| description="Device to use for computation (rendering with Cycles)", | description="Device to use for computation (rendering with Cycles)", | ||||
| items=get_device_types, | items=get_device_types, | ||||
| ) | ) | ||||
| devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings) | devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings) | ||||
| def get_devices(self): | def get_devices(self): | ||||
| import _cycles | import _cycles | ||||
| # Layout of the device tuples: (Name, Type, Internal ID, Persistent ID) | # Layout of the device tuples: (Name, Type, Persistent ID) | ||||
| device_list = _cycles.available_devices() | device_list = _cycles.available_devices() | ||||
| cuda_devices = [] | cuda_devices = [] | ||||
| opencl_devices = [] | opencl_devices = [] | ||||
| for device in device_list: | for device in device_list: | ||||
| if not device[1] in {'CUDA', 'OPENCL'}: | if not device[1] in {'CUDA', 'OPENCL'}: | ||||
| continue | continue | ||||
| Show All 31 Lines | def get_num_gpu_devices(self): | ||||
| return num | return num | ||||
| def has_active_device(self): | def has_active_device(self): | ||||
| return self.get_num_gpu_devices() > 0 | return self.get_num_gpu_devices() > 0 | ||||
| def draw_impl(self, layout, context): | def draw_impl(self, layout, context): | ||||
| layout.label(text="Compute Device:") | layout.label(text="Cycles Compute Device:") | ||||
| layout.row().prop(self, "compute_device_type", expand=True) | layout.row().prop(self, "compute_device_type", expand=True) | ||||
| cuda_devices, opencl_devices = self.get_devices() | cuda_devices, opencl_devices = self.get_devices() | ||||
| row = layout.row() | row = layout.row() | ||||
| if cuda_devices: | if self.compute_device_type == 'CUDA' and cuda_devices: | ||||
| col = row.column(align=True) | col = row.column(align=True) | ||||
| col.label(text="CUDA devices:") | |||||
| for device in cuda_devices: | for device in cuda_devices: | ||||
| col.prop(device, "use", text=device.name, toggle=True) | col.prop(device, "use", text=device.name, toggle=True) | ||||
| if opencl_devices: | if self.compute_device_type == 'OPENCL' and opencl_devices: | ||||
| col = row.column(align=True) | col = row.column(align=True) | ||||
| col.label(text="OpenCL devices:") | |||||
| for device in opencl_devices: | for device in opencl_devices: | ||||
| col.prop(device, "use", text=device.name, toggle=True) | col.prop(device, "use", text=device.name, toggle=True) | ||||
| def draw(self, context): | def draw(self, context): | ||||
| self.draw_impl(self.layout, context) | self.draw_impl(self.layout, context) | ||||
| Show All 28 Lines | |||||