Reputation: 1239
I have a rendering intensive game and using png it's too slow to run on 3G phones. But it runs fast using pvrtc so I need to know what model I'm running on.
Question: how can I detect the hardware I'm running on?
Many thanks for your help!
Upvotes: 3
Views: 509
Reputation: 100652
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).
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. 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.
Upvotes: 3
Reputation: 2976
You could also disable Thumb for the armv6 build. This will speed up the game on older models. You should leave Thumb enabled for the armv7 architecture, though.
Upvotes: 0
Reputation: 69499
Compile for ARM v7 only, all iPhone after the 3G are ARM v7.
This is what the layar app also does.
If you want to detect the older hardware is even easier, since you are creating a fat binary (support for ARMv6 and ARMv7). There is a define for the ARMv&, just can't find it write now. 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.
Upvotes: 0
Reputation: 104115
See my example gist, the core is the following method:
- (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;
}
Upvotes: 1