Cycles: Gray out hardware raytracing checkboxes when not available

HWRT checkboxes visibility in the Cycles settings wasn't uniform across devices.
With this change, we unify it and gray out these in case HWRT isn't available.

Pull Request: https://projects.blender.org/blender/blender/pulls/117904
This commit is contained in:
Nikita Sirgienko
2024-02-06 20:06:13 +01:00
committed by Nikita Sirgienko
parent 0d7282e69b
commit 0100547515

View File

@@ -1711,12 +1711,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()
@@ -1734,25 +1735,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']:
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']
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']
row.prop(self, "use_oneapirt")
def draw(self, context):