Cycles: Remove MetalRT experimental status, and add "auto enable" option

This PR removes the "experimental" disclaimer from the MetalRT control now that the unit tests all render correctly with it enabled. As well as "Off" and "On", this adds a third "Auto" setting  - a new default which can be used to pick the best option.

Pull Request: https://projects.blender.org/blender/blender/pulls/114067
This commit is contained in:
Michael Jones
2023-10-24 14:33:47 +02:00
committed by Michael Jones (Apple)
parent bef2155baa
commit af629b8c20
3 changed files with 31 additions and 7 deletions

View File

@@ -1477,11 +1477,16 @@ class CyclesPreferences(bpy.types.AddonPreferences):
default=False,
)
use_metalrt: BoolProperty(
name="MetalRT (Experimental)",
metalrt: EnumProperty(
name="MetalRT",
description="MetalRT for ray tracing uses less memory for scenes which use curves extensively, and can give better "
"performance in specific cases. However this support is experimental and some scenes may render incorrectly",
default=False,
"performance in specific cases.",
default='AUTO',
items=(
('OFF', "Off", "Disable MetalRT (uses BVH2 layout for intersection queries)"),
('ON', "On", "Enable MetalRT for intersection queries"),
('AUTO', "Auto", "Automatically pick the fastest intersection method"),
),
)
use_hiprt: BoolProperty(
@@ -1716,7 +1721,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
if is_arm64:
col.prop(self, "kernel_optimization_level")
if has_rt_api_support:
col.prop(self, "use_metalrt")
col.prop(self, "metalrt")
if compute_device_type == 'HIP':
has_cuda, has_optix, has_hip, has_metal, has_oneapi, has_hiprt = _cycles.get_device_types()

View File

@@ -39,8 +39,17 @@ void static adjust_device_info_from_preferences(DeviceInfo &info, PointerRNA cpr
info.has_peer_memory = false;
}
if (info.type == DEVICE_METAL && !get_boolean(cpreferences, "use_metalrt")) {
info.use_hardware_raytracing = false;
if (info.type == DEVICE_METAL) {
MetalRTSetting use_metalrt = (MetalRTSetting)get_enum(
cpreferences, "metalrt", METALRT_NUM_SETTINGS, METALRT_AUTO);
info.use_hardware_raytracing = info.use_metalrt_by_default;
if (use_metalrt == METALRT_OFF) {
info.use_hardware_raytracing = false;
}
else if (use_metalrt == METALRT_ON) {
info.use_hardware_raytracing = true;
}
}
if (info.type == DEVICE_ONEAPI && !get_boolean(cpreferences, "use_oneapirt")) {

View File

@@ -67,6 +67,14 @@ enum KernelOptimizationLevel {
KERNEL_OPTIMIZATION_NUM_LEVELS
};
enum MetalRTSetting {
METALRT_OFF = 0,
METALRT_ON = 1,
METALRT_AUTO = 2,
METALRT_NUM_SETTINGS
};
class DeviceInfo {
public:
DeviceType type;
@@ -83,6 +91,7 @@ class DeviceInfo {
bool has_peer_memory; /* GPU has P2P access to memory of another GPU. */
bool has_gpu_queue; /* Device supports GPU queue. */
bool use_hardware_raytracing; /* Use hardware instructions to accelerate ray tracing. */
bool use_metalrt_by_default; /* Use MetalRT by default. */
KernelOptimizationLevel kernel_optimization_level; /* Optimization level applied to path tracing
* kernels (Metal only). */
DenoiserTypeMask denoisers; /* Supported denoiser types. */
@@ -106,6 +115,7 @@ class DeviceInfo {
has_peer_memory = false;
has_gpu_queue = false;
use_hardware_raytracing = false;
use_metalrt_by_default = false;
denoisers = DENOISER_NONE;
}