iOS code to identify metal support in runtime?

后端 未结 4 1427
迷失自我
迷失自我 2021-02-13 15:51

Usually, I use the below code to identify the iOS version of the device.

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)

In

4条回答
  •  别跟我提以往
    2021-02-13 16:27

    On iOS, you should just check MTLCreateSystemDefaultDevice(). If it returns a valid device, you’re good to go. On macOS, you need to be careful; use [MTLCopyAllDevices() count] to determine if you have any supported metal devices available.

    You should avoid using MTLCreateSystemDefaultDevice() on macOS because that can force a mux switch to the discrete GPU (eg: if you're dealing with a laptop with automatic graphics switching between a discrete and integrated graphics).

提交回复
热议问题