Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/addon/properties.py
| Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | enum_world_mis = ( | ||||
| ('AUTOMATIC', "Auto", "Automatically try to determine the best setting"), | ('AUTOMATIC', "Auto", "Automatically try to determine the best setting"), | ||||
| ('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise") | ('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise") | ||||
| ) | ) | ||||
| enum_device_type = ( | enum_device_type = ( | ||||
| ('CPU', "CPU", "CPU", 0), | ('CPU', "CPU", "CPU", 0), | ||||
| ('CUDA', "CUDA", "CUDA", 1), | ('CUDA', "CUDA", "CUDA", 1), | ||||
| ('OPTIX', "OptiX", "OptiX", 3), | ('OPTIX', "OptiX", "OptiX", 3), | ||||
| ("HIP", "HIP", "HIP", 4) | ('HIP', "HIP", "HIP", 4), | ||||
| ('METAL', "Metal", "Metal", 5) | |||||
| ) | ) | ||||
| enum_texture_limit = ( | enum_texture_limit = ( | ||||
| ('OFF', "No Limit", "No texture size limit", 0), | ('OFF', "No Limit", "No texture size limit", 0), | ||||
| ('128', "128", "Limit texture size to 128 pixels", 1), | ('128', "128", "Limit texture size to 128 pixels", 1), | ||||
| ('256', "256", "Limit texture size to 256 pixels", 2), | ('256', "256", "Limit texture size to 256 pixels", 2), | ||||
| ('512', "512", "Limit texture size to 512 pixels", 3), | ('512', "512", "Limit texture size to 512 pixels", 3), | ||||
| ('1024', "1024", "Limit texture size to 1024 pixels", 4), | ('1024', "1024", "Limit texture size to 1024 pixels", 4), | ||||
| ▲ Show 20 Lines • Show All 1,184 Lines • ▼ Show 20 Lines | class CyclesDeviceSettings(bpy.types.PropertyGroup): | ||||
| type: EnumProperty(name="Type", items=enum_device_type, default='CUDA') | type: EnumProperty(name="Type", items=enum_device_type, default='CUDA') | ||||
| class CyclesPreferences(bpy.types.AddonPreferences): | class CyclesPreferences(bpy.types.AddonPreferences): | ||||
| bl_idname = __package__ | bl_idname = __package__ | ||||
| def get_device_types(self, context): | def get_device_types(self, context): | ||||
| import _cycles | import _cycles | ||||
| has_cuda, has_optix, has_hip = _cycles.get_device_types() | has_cuda, has_optix, has_hip, has_metal = _cycles.get_device_types() | ||||
| list = [('NONE', "None", "Don't use compute device", 0)] | list = [('NONE', "None", "Don't use compute device", 0)] | ||||
| if has_cuda: | if has_cuda: | ||||
| list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1)) | list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1)) | ||||
| if has_optix: | if has_optix: | ||||
| list.append(('OPTIX', "OptiX", "Use OptiX for GPU acceleration", 3)) | list.append(('OPTIX', "OptiX", "Use OptiX for GPU acceleration", 3)) | ||||
| if has_hip: | if has_hip: | ||||
| list.append(('HIP', "HIP", "Use HIP for GPU acceleration", 4)) | list.append(('HIP', "HIP", "Use HIP for GPU acceleration", 4)) | ||||
| if has_metal: | |||||
| list.append(('METAL', "Metal", "Use Metal for GPU acceleration", 5)) | |||||
| return list | return list | ||||
| compute_device_type: EnumProperty( | compute_device_type: EnumProperty( | ||||
| name="Compute Device Type", | name="Compute Device Type", | ||||
| description="Device to use for computation (rendering with Cycles)", | description="Device to use for computation (rendering with Cycles)", | ||||
| items=CyclesPreferences.get_device_types, | items=CyclesPreferences.get_device_types, | ||||
| ) | ) | ||||
| Show All 9 Lines | class CyclesPreferences(bpy.types.AddonPreferences): | ||||
| def find_existing_device_entry(self, device): | def find_existing_device_entry(self, device): | ||||
| for device_entry in self.devices: | for device_entry in self.devices: | ||||
| if device_entry.id == device[2] and device_entry.type == device[1]: | if device_entry.id == device[2] and device_entry.type == device[1]: | ||||
| return device_entry | return device_entry | ||||
| return None | return None | ||||
| def update_device_entries(self, device_list): | def update_device_entries(self, device_list): | ||||
| for device in device_list: | for device in device_list: | ||||
| if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP'}: | if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP', 'METAL'}: | ||||
| continue | continue | ||||
| # Try to find existing Device entry | # Try to find existing Device entry | ||||
| entry = self.find_existing_device_entry(device) | entry = self.find_existing_device_entry(device) | ||||
| if not entry: | if not entry: | ||||
| # Create new entry if no existing one was found | # Create new entry if no existing one was found | ||||
| entry = self.devices.add() | entry = self.devices.add() | ||||
| entry.id = device[2] | entry.id = device[2] | ||||
| entry.name = device[0] | entry.name = device[0] | ||||
| Show All 27 Lines | def get_devices_for_type(self, compute_device_type): | ||||
| return devices | return devices | ||||
| # Refresh device list. This does not happen automatically on Blender | # Refresh device list. This does not happen automatically on Blender | ||||
| # startup due to unstable OpenCL implementations that can cause crashes. | # startup due to unstable OpenCL implementations that can cause crashes. | ||||
| def refresh_devices(self): | def refresh_devices(self): | ||||
| import _cycles | import _cycles | ||||
| # Ensure `self.devices` is not re-allocated when the second call to | # Ensure `self.devices` is not re-allocated when the second call to | ||||
| # get_devices_for_type is made, freeing items from the first list. | # get_devices_for_type is made, freeing items from the first list. | ||||
| for device_type in ('CUDA', 'OPTIX', 'HIP'): | for device_type in ('CUDA', 'OPTIX', 'HIP', 'METAL'): | ||||
| self.update_device_entries(_cycles.available_devices(device_type)) | self.update_device_entries(_cycles.available_devices(device_type)) | ||||
| # Deprecated: use refresh_devices instead. | # Deprecated: use refresh_devices instead. | ||||
| def get_devices(self, compute_device_type=''): | def get_devices(self, compute_device_type=''): | ||||
| self.refresh_devices() | self.refresh_devices() | ||||
| return None | return None | ||||
| def get_compute_device_type(self): | def get_compute_device_type(self): | ||||
| ▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines | |||||