Sunday, November 30, 2008

iP* programming tip #1

This is the first of a series of iPhone / iPod programming tips.
Starting iPhone development requires first the knowledge of the underlying hardware and what it can do for you. Here are the latest hardware specs I am aware of (a rumour was talking about iPods that run the CPU with 532 MHz ... I haven't found any evidence for this).
  • GPU: PowerVR MBXLite with VGPLite with 103 Mhz
  • ~DX8 hardware with vs_1_1 and ps_1_1 functionality
  • Vertex shader is not exposed
  • Pixel shader is programmed with texture combiners
  • 16 MB VRAM – not mentioned anywhere
  • CPU: ARM 1176 with 412 Mhz (can do 600 Mhz)
  • VFP unit 128-bit Multimedia unit ~= SIMD unit
  • 128 MB RAM; only 24 MB for apps allowed
  • 320x480 px at 163 ppi screen
  • LIS302DL, a 3-axis accelerometer with 412 Mhz (?) update rate
  • Multi-Touch: up to five fingers
  • PVRTC texture compression: color map 2-bit per pixel and normal map 4-bit per-pixel
The interesting part is that the CPU can do up to 600 Mhz, so it would be possible to increase the performance here in the future.
I wonder how the 16 MB VRAM are handled. I assume that this is the place where the VBO and textures are stored. Regarding the max size of apps of 24 MB; I wonder what happens if an application generates geometry and textures dynamically ... when does the sandbox of the iPhone / iPod touch stop the application. I did not find any evidence for this.


NeARAZ said...

Is it really ps_1_1 capable? My understanding is that the pixel pipe is more like GeForce 2 - two texture stages with ARB combiner operations on them (including dot3). No cubemaps though.

The vertex pipe is vs_1_1 capable in theory, however current Apple drivers don't expose that. So again, pushing back into GeForce 2 capability.

Cort said...

Thanks for the summary; please keep this information coming! I just upgraded to an iPhone this weekend, and am eagerly looking forward to poking around under the hood...

Mikko Mononen said...

It seems pretty much like GF2 with its two texture stages, there is no cross-bar either.

LIS302DL is capable of sampling at 100-400 Hz ( I have not measured the actual call back rate. In practice, it seems a bit more accurate and less jittery than the accelerometers found in Wii or Sixaxis.

I was always under the assumption that iP* did not use VRAM for textures and VBOs. At least I did not get any speed up when I switched from VAs to VBOs. But I did get a great boost when I switched to interleaved and smaller vertex size.

Dynamic textures are a bit no-no. Updating 64x64 8bit texture per frame eats quite a bit of frame time (about 7% @ 25fps). The driver seems to spend quite some time swizzling the data. I think the SDK supports client storage extension. I have not tried that yet, though.

I'm updating partial data on 2k vertex buffer per frame and that does not seem to slow things down that much (versus not updating it at all).

From my experience the key seems to be to keep the amount of data small. Use smallest possible vertex data (shorts for verts, bytes for tcoords and normals). Dynamic vertex data does not seem to be a problem.

I have a bit special type of rendering and I go as far as updating my index buffer every frame to omit any triangles that do not contribute to the final image and the extra work seemed to help quite a bit.

On a tangent... I wish they had done better job with the SoundEngine sample code. In theory it covers all the sound needs a medium sized game has. It looks like a lot of people are using it and while the code looks tempting to use, it has so many nasty bugs that I wonder who wrote it :)

Unknown said...

Couple of things I couldn't easily google up or find in the SDK, I'd appreciate if you could help.
- Is it able to render to texture at all? I assume it should, but couldn't find relevant functions in OpenGL ES spec.
- Seriously, slow dynamic textures and no way around it? Why is it slow? (if it's swizzling, can I disable it?)
- If dynamic texture are slow, how do you play video? More than that, is GPU video decoding functionality exposed at all, or just Apple controls could use it?
- What's the deal with PowerVR being a tiled rendering? Does MBX Lite use it as well?

Thanks :)

sayjava said...

I started to learn c++ lately but I have also developed some interest in iphone games development. Do you think I need to know objective-C or should I stick with C++ for games development.