Cycles: Allow get_apple_gpu_architecture to report non Apple GPUs #120448

Merged
Brecht Van Lommel merged 3 commits from Alaska/blender:complex-120299 into main 2024-04-15 15:04:36 +02:00
3 changed files with 10 additions and 6 deletions

View File

@ -77,12 +77,8 @@ void device_metal_info(vector<DeviceInfo> &devices)
if (@available(macos 14.0, *)) {
info.use_hardware_raytracing = device.supportsRaytracing;
info.use_metalrt_by_default = false;
if (vendor == METAL_GPU_APPLE) {
/* Use hardware raytracing for faster rendering on architectures that support it. */
info.use_metalrt_by_default = (MetalInfo::get_apple_gpu_architecture(device) >=
APPLE_M3);
}
/* Use hardware raytracing for faster rendering on architectures that support it. */
info.use_metalrt_by_default = (MetalInfo::get_apple_gpu_architecture(device) >= APPLE_M3);
}
}
# endif

View File

@ -27,6 +27,10 @@ enum MetalGPUVendor {
};
enum AppleGPUArchitecture {
/* NOT_APPLE_GPU represents AMD/Intel GPUs. This should remained at the start of this enum to
* ensure that AMD/Intel GPUs don't accidentally get Apple Silicon only features enabled when
* using comparison operators. */
NOT_APPLE_GPU,
APPLE_M1,
APPLE_M2,
APPLE_M2_BIG,

View File

@ -49,6 +49,10 @@ int MetalInfo::get_apple_gpu_core_count(id<MTLDevice> device)
AppleGPUArchitecture MetalInfo::get_apple_gpu_architecture(id<MTLDevice> device)
{
if (MetalInfo::get_device_vendor(device) != METAL_GPU_APPLE) {
return NOT_APPLE_GPU;
}
const char *device_name = [device.name UTF8String];
if (strstr(device_name, "M1")) {
return APPLE_M1;