简体   繁体   English

检测比3GS更旧的iPhone硬件

[英]Detect iPhone hardware older than 3GS

I have a rendering intensive game and using png it's too slow to run on 3G phones. 我有一个渲染密集型游戏,使用png它太慢,无法在3G手机上运行。 But it runs fast using pvrtc so I need to know what model I'm running on. 但它使用pvrtc快速运行所以我需要知道我正在运行的模型。

Question: how can I detect the hardware I'm running on? 问题:如何检测我正在运行的硬件?

Many thanks for your help! 非常感谢您的帮助!

What you're probably actually interested is whether you're on PowerVR MBX hardware (as in the 3G, the original iPhone, the first and second generation iPod Touches and the low-end third generation iPod) or PowerVR SGX hardware (as in the 3GS and iPhone 4, both iPads and the iPod Touches not in the above list). 您可能真正感兴趣的是您是使用PowerVR MBX硬件(如3G,原始iPhone,第一代和第二代iPod Touch和低端第三代iPod)还是PowerVR SGX硬件(如3GS和iPhone 4,iPad和iPod Touch都不在上面的列表中)。

With that in mind, how about just: 考虑到这一点,如何:

EAGLContext *testContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

BOOL isSGX = testContext ? YES : NO;
[testContext release];

return isSGX;

The SGX is a programmable part that can support ES 2, the MBX isn't. SGX是可编程部件,可以支持ES 2,而MBX则不支持。 The MBX is also limited to 16mb of VRAM whereas the SGX isn't, which is probably why your app runs poorly with full fat textures but fine with pvrtc. MBX也仅限于16MB的VRAM,而SGX则不然,这可能就是为什么你的应用程序在全脂纹理下运行不佳但pvrtc很好。

你可以使用Erica Sadun的这个课程

See my example gist , the core is the following method: 看我的示例gist ,核心是以下方法:

- (NSString*) platformID
{
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithUTF8String:machine];
    free(machine);
    return platform;
}

Compile for ARM v7 only, all iPhone after the 3G are ARM v7. 仅针对ARM v7进行编译,3G之后的所有iPhone都是ARM v7。

This is what the layar app also does. 这就是layar应用程序也能做到的。

If you want to detect the older hardware is even easier, since you are creating a fat binary (support for ARMv6 and ARMv7). 如果您想要检测旧硬件更容易,因为您正在创建胖二进制文件(支持ARMv6和ARMv7)。 There is a define for the ARMv&, just can't find it write now. 有一个ARMv&的定义,现在找不到它。 This way you do not have to loop up the type at runt time, just create a fat binary for ARMv6 and ARMv7 then with a macro add the optimization for the ARMv& with the #if armv7 macro. 这样你就不必在runt时循环这个类型,只需为ARMv6和ARMv7创建一个胖二进制文件,然后用宏添加ARMv的优化和#if armv7宏。

You could also disable Thumb for the armv6 build. 你也可以为armv6版本禁用Thumb。 This will speed up the game on older models. 这将加速老款车型的游戏。 You should leave Thumb enabled for the armv7 architecture, though. 但是,您应该为armv7架构启用Thumb。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM