Cycles: Gray out hardware raytracing checkboxes when not available #117904

Merged
Nikita Sirgienko merged 2 commits from Sirgienko/blender:ui_setting_rthw_checkbox_unification into main 2024-02-06 20:06:22 +01:00
1 changed files with 7 additions and 6 deletions

View File

@ -1685,12 +1685,13 @@ class CyclesPreferences(bpy.types.AddonPreferences):
import _cycles
has_peer_memory = 0
has_rt_api_support = False
has_rt_api_support = {'METAL': False, 'HIP': False, 'ONEAPI': False}
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 device[4] and self.find_existing_device_entry(device).use:
has_rt_api_support = True
device_type = device[1]
has_rt_api_support[device_type] = True
if has_peer_memory > 1:
row = layout.row()
@ -1708,25 +1709,25 @@ class CyclesPreferences(bpy.types.AddonPreferences):
# MetalRT only works on Apple Silicon and Navi2.
is_arm64 = platform.machine() == 'arm64'
if is_arm64 or (is_navi_2 and has_rt_api_support):
if is_arm64 or (is_navi_2 and has_rt_api_support['METAL']):
col = layout.column()
col.use_property_split = True
# Kernel specialization is only supported on Apple Silicon
if is_arm64:
col.prop(self, "kernel_optimization_level")
if has_rt_api_support:
if has_rt_api_support['METAL']:

We could gray out here too for consistency, as you mentioned.

We could gray out here too for consistency, as you mentioned.
Review

I could, but I have decided to leave this change to the Apple people - maybe they have some strong opinion why this option should disappear on MacOS instead of being gray out.

I could, but I have decided to leave this change to the Apple people - maybe they have some strong opinion why this option should disappear on MacOS instead of being gray out.

Ok, does not need to be done as part of this PR.

Ok, does not need to be done as part of this PR.
col.prop(self, "metalrt")
if compute_device_type == 'HIP':
import platform
if platform.system() == "Windows": # HIP-RT is currently only supported on Windows
has_cuda, has_optix, has_hip, has_metal, has_oneapi, has_hiprt = _cycles.get_device_types()
row = layout.row()
row.enabled = has_hiprt
row.active = has_rt_api_support['HIP']
Sirgienko marked this conversation as resolved Outdated

Use row.active. No reason to disallow toggling the option entirely, just graying out is enough.

Use `row.active`. No reason to disallow toggling the option entirely, just graying out is enough.
row.prop(self, "use_hiprt")
elif compute_device_type == 'ONEAPI' and _cycles.with_embree_gpu:
row = layout.row()
row.active = has_rt_api_support['ONEAPI']
Sirgienko marked this conversation as resolved Outdated

Same comment.

Same comment.
row.prop(self, "use_oneapirt")
def draw(self, context):