mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 11:44:18 +01:00
41 lines
1.3 KiB
Objective-C
41 lines
1.3 KiB
Objective-C
|
|
#include "gpu.h"
|
||
|
|
|
||
|
|
#import <Metal/MTLDevice.h>
|
||
|
|
|
||
|
|
#ifndef MAC_OS_VERSION_13_0
|
||
|
|
#define MTLGPUFamilyMetal3 ((MTLGPUFamily) 5001)
|
||
|
|
#endif
|
||
|
|
|
||
|
|
const char* ffGpuDetectMetal(FFlist* gpus)
|
||
|
|
{
|
||
|
|
if (@available(macOS 10.15, *))
|
||
|
|
{
|
||
|
|
for (id<MTLDevice> device in MTLCopyAllDevices())
|
||
|
|
{
|
||
|
|
FFGPUResult* gpu = NULL;
|
||
|
|
FF_LIST_FOR_EACH(FFGPUResult, x, *gpus)
|
||
|
|
{
|
||
|
|
if (x->deviceId == device.registryID || ffStrbufEqualS(&x->name, device.name.UTF8String))
|
||
|
|
{
|
||
|
|
gpu = x;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!gpu) continue;
|
||
|
|
|
||
|
|
if ([device supportsFamily:MTLGPUFamilyMetal3])
|
||
|
|
ffStrbufSetStatic(&gpu->platformApi, "Metal 3");
|
||
|
|
else if ([device supportsFamily:MTLGPUFamilyCommon3])
|
||
|
|
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 3");
|
||
|
|
else if ([device supportsFamily:MTLGPUFamilyCommon2])
|
||
|
|
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 2");
|
||
|
|
else if ([device supportsFamily:MTLGPUFamilyCommon1])
|
||
|
|
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 1");
|
||
|
|
|
||
|
|
gpu->type = device.hasUnifiedMemory ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return NULL;
|
||
|
|
}
|