Tuesday, December 23, 2008

OpenGL ES Extensions on the iPhone

I was recently re-reading Brian Greenstone's excellent (if slightly dated) Pangea Software's Ultiamte Game Programming Guide for Mac OS X (which is now available as a free download), and was wondering if I could use one of the optimizations Brian talked about in his book: vertex array ranges.

Brian Greenstone, if you don't know, has been writing games for years, starting on the Apple //gs, if I remember correctly, then moving to the Mac, then later the iPhone. He knows probably better than any living person - at very least any living person outside of 1 Infinite Loop, Cupertino, CA - how to get the best 3D performance out of Apple hardware, so if he suggests something, it's a good idea to listen.

To discover whether Vertex Array Ranges were supported, I used the following code:
    NSString *extensionString = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)];
NSArray *extensions = [extensionString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
for (NSString *oneExtension in extensions)
NSLog(oneExtension);
Which simply dumps a list of the OpenGL extensions supported by the device to the console. Here is the list I get when running on my first generation iPhone (Note: running against the simulator will give you a slightly different list):

GL_EXT_texture_filter_anisotropic
GL_EXT_texture_lod_bias
GL_IMG_read_format
GL_IMG_texture_compression_pvrtc
GL_IMG_texture_format_BGRA8888
GL_OES_blend_subtract
GL_OES_compressed_paletted_texture
GL_OES_depth24
GL_OES_draw_texture
GL_OES_framebuffer_object
GL_OES_mapbuffer
GL_OES_matrix_palette
GL_OES_point_size_array
GL_OES_point_sprite
GL_OES_read_format
GL_OES_rgb8_rgba8
GL_OES_texture_mirrored_repeat

Unless I'm reading it wrong, it looks like vertex array ranges are not supported on the iPhone.

Let's hope Brian decides to write an iPhone Ultimate Game Programming Guide.



5 comments:

Gavin Bowman said...

It sounds like what you're looking for is Vertex Buffer Objects. When you have a large array of static geometry info you can pass it into a openGL buffer object, which I think is similar conceptually to passing the large array of pixel data into a texture object when you create an openGL texture. VBOs are supported on the iPhone, it's part of the ES1.1 spec.

Jeff LaMarche said...

That does look very similar to VARs which, I believe, are a Mac-specific optimization. I'll have to try it out and see if it helps my performance at all. Thanks!

TomGidden said...

Apparently (anecdotally, and with a few quick benchmarks), VBOs don't seem to have any performance benefits over just passing arrays on current iPhone hardware. In fact, the overhead of binding the VBO adds a (tiny) performance cost.

YMMV, however!

Torbjörn Laedre said...

vertex_array_range and its partner fence were Nvidia extensions launched for the GeForce 2, IIRC (NV_vertex_array_range and NV_fence). I'm assuming Apple later adopted those for their nv based systems.

As for VBOs, Apple devrel has told the official story about those in the developer program forum, so if you're still curious, search for it there.

h4ns said...

What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.

Arsenal vs Huddersfield Town live streaming
Arsenal vs Huddersfield Town live streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Notts County vs Manchester City Live Streaming
Notts County vs Manchester City Live Streaming
Bologna vs AS Roma Live Streaming
Bologna vs AS Roma Live Streaming
Juventus vs Udinese Live Streaming
Juventus vs Udinese Live Streaming
Napoli vs Sampdoria Live Streaming
Napoli vs Sampdoria Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
AS Monaco vs Marseille Live Streaming
AS Monaco vs Marseille Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Technology News | News Today | Live Streaming TV Channels