iOS代码在运行时识别金属支持? [英] iOS code to identify metal support in runtime?

查看:211
本文介绍了iOS代码在运行时识别金属支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我使用以下代码来识别设备的iOS版本。

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

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

以类似的方式,我试图找到金属支持该设备。使用A7(或更好)GPU和iOS 8.0的Apple设备支持Metal。

In a similar way, I'm trying to find Metal support for the device. Metal is supported for Apple devices with the A7 (or better) GPU and iOS 8.0.

这是我期望我的代码工作的方式:

This is the way I expect my code to work:

if (MetalSupported == true) {
  // metal programming
} else {
  // opengles2 programming
}

如何获取布尔变量的值 MetalSupported

How do I get the value for the Boolean variable MetalSupported ?

推荐答案

您正在寻找特定金属的东西 - 通常是iOS版本检查和硬件名称检查是脆弱的,因为它们依赖于您的应用程序,了解所有可以运行它的操作系统版本和设备。如果Apple要回去发布一个增加了Metal支持的iOS 7.x版本(好吧,似乎不太可能),或者支持Metal但不是你正在考虑的硬件名称的设备(似乎更有可能) ),你将不得不追踪所有这些事情并更新你的应用程序来管理它们。

It's good that you're looking for something specific to Metal — generally, iOS version checks and hardware name checks are fragile, because they rely on your app knowing all of the OS versions and devices that could ever run it. If Apple were to go back and release an iOS 7.x version that added Metal support (okay, seems unlikely), or a device that supports Metal but isn't one of the hardware names you're looking at (seems much more likely), you'd be stuck having to track all of those things down and update your app to manage them.

无论如何,最好的方法来检查你的设备是否是'重新运行是金属足够你的真棒图形代码?只是尝试获得 MTLDevice 对象:

Anyway, the best way to check whether the device you're running on is Metal enough for your awesome graphics code? Just try to get a MTLDevice object:

这篇关于iOS代码在运行时识别金属支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆